Module: Drakkon::Skeleton::CLI

Defined in:
lib/drakkon/skeleton/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/skeleton/cli.rb', line 5

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

  @args
end

.init!(raw) ⇒ Object

General Run



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

def self.init!(raw)
  args(raw)
  cmd = args.shift

  start(cmd&.to_sym)
end


33
34
35
36
37
38
39
40
# File 'lib/drakkon/skeleton/cli.rb', line 33

def self.menu
  prompt.select('Wat do?', filter: true) do |menu|
    menu.choice name: 'install (New Templates)', value: :install
    menu.choice name: 'deploy', value: :deploy if Hub.skeletons?
  end
rescue TTY::Reader::InputInterrupt
  exit 0
end

.promptObject



29
30
31
# File 'lib/drakkon/skeleton/cli.rb', line 29

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

.start(cmd) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/drakkon/skeleton/cli.rb', line 19

def self.start(cmd)
  case cmd
  when :install then Skeleton::Install.new(args)
  when :deploy then Skeleton::Deploy.start(args)

  else
    start(menu)
  end
end