Module: Drakkon::CLI

Defined in:
lib/drakkon/cli.rb

Overview

General Entrypoint for CLI

Class Method Summary collapse

Class Method Details

.consoleObject



41
42
43
# File 'lib/drakkon/cli.rb', line 41

def self.console
  binding.pry
end

.initObject

Entrypoint for the CLI



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

def self.init
  # Home Directory Handling
  Hub.init

  # Split up CLI Args
  cmd = ARGV[0]
  args = ARGV[1..]

  start(cmd&.to_sym, args)
end


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/drakkon/cli.rb', line 45

def self.menu
  prompt.select('Wat do?', filter: true, per_page: 100) do |menu|
    menu.choice name: 'run', value: :run
    menu.choice name: 'setup (config/initialization)', value: :setup
    menu.choice name: 'build', value: :build
    menu.choice name: 'publish', value: :publish
    menu.choice name: 'install (DragonRuby Versions)', value: :install
    menu.choice name: 'Image Helpers [images]', value: :images
    menu.choice name: 'Utilities [utils]', value: :utils
    menu.choice name: 'gem (Shared Code)', value: :gem
    menu.choice name: 'skeleton (Templates)', value: :skeleton
    menu.choice name: 'console (pry)', value: :console
    menu.choice name: 'exit', value: :exit
  end
rescue TTY::Reader::InputInterrupt
  exit 0
end

.promptObject



37
38
39
# File 'lib/drakkon/cli.rb', line 37

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

.start(cmd, args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/drakkon/cli.rb', line 16

def self.start(cmd, args)
  case cmd
  when :init then Init.go!(args)
  when :setup then Setup.go!(args)
  when :run then Run.go!(args)
  when :build then Build.go!(args)
  when :publish then Build.go!([], '')
  when :images then Images::CLI.run!(args)
  when :utils then Utils::CLI.run!(args)
  when :install then Version.install!(args)
  when :gem then Gems::CLI.init!(args)
  when :skeleton then Skeleton::CLI.init!(args)
  when :versions then Version.list
  when :console then console
  when :web then Web.run!(args)
  when :exit then exit(0)
  else
    start(menu, args)
  end
end