Module: Drakkon::Utils::CLI

Defined in:
lib/drakkon/lib/utils/cli.rb

Overview

General Entry Point For Images Subcommand

Class Method Summary collapse

Class Method Details



23
24
25
26
27
28
29
# File 'lib/drakkon/lib/utils/cli.rb', line 23

def self.menu
  prompt.select('Utilties:', filter: true, per_page: 20) do |menu|
    menu.choice name: 'Rename Files - Normalize [normalize]', value: :normalize
  end
rescue TTY::Reader::InputInterrupt
  exit 0
end

.promptObject



31
32
33
# File 'lib/drakkon/lib/utils/cli.rb', line 31

def self.prompt
  TTY::Prompt.new(active_color: :cyan, interrupt: :exit)
end

.run!(args = []) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/drakkon/lib/utils/cli.rb', line 5

def self.run!(args = [])
  args ||= []
  cmd = if args.empty?
          nil
        else
          args.shift.to_sym
        end
  start(cmd, args)
end

.start(cmd, args) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/drakkon/lib/utils/cli.rb', line 15

def self.start(cmd, args)
  case cmd
  when :normalize then Utils::DowncaseNormalize.run!(args)
  else
    start(menu, args)
  end
end