Module: Drakkon::CLI

Defined in:
lib/drakkon/cli.rb

Overview

General Entrypoint for CLI

Class Method Summary collapse

Class Method Details

.consoleObject



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

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


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

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: 'images', value: :images
    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



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

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
# 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 :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