Module: Drakkon::Gems::CLI

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

Overview

Run Command for CLI

Class Method Summary collapse

Class Method Details

.args(raw = []) ⇒ Object



5
6
7
8
9
# File 'lib/drakkon/gem/cli.rb', line 5

def self.args(raw = [])
  @args ||= raw

  @args
end

.init!(raw) ⇒ Object

General Run



12
13
14
15
16
17
18
19
# File 'lib/drakkon/gem/cli.rb', line 12

def self.init!(raw)
  Settings.ready?

  args(raw)
  cmd = args.shift

  start(cmd&.to_sym)
end


35
36
37
38
39
40
41
42
# File 'lib/drakkon/gem/cli.rb', line 35

def self.menu
  prompt.select('Wat do?', filter: true) do |menu|
    menu.choice name: 'install (New Gem)', value: :install
    menu.choice name: 'configure', value: :configure unless Settings.gems.empty?
  end
rescue TTY::Reader::InputInterrupt
  exit 0
end

.promptObject



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

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

.start(cmd) ⇒ Object



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

def self.start(cmd)
  case cmd
  when :install then Gems::Install.start(args)
  when :configure then Gems::Configure.start(args)

  else
    start(menu)
  end
end