Module: Drakkon::CLI
- Defined in:
- lib/drakkon/cli.rb
Overview
General Entrypoint for CLI
Class Method Summary collapse
- .console ⇒ Object
-
.init ⇒ Object
Entrypoint for the CLI.
- .menu ⇒ Object
- .prompt ⇒ Object
- .start(cmd, args) ⇒ Object
Class Method Details
.console ⇒ Object
41 42 43 |
# File 'lib/drakkon/cli.rb', line 41 def self.console binding.pry end |
.init ⇒ Object
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 |
.menu ⇒ Object
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. prompt.select('Wat do?', filter: true, per_page: 100) do || .choice name: 'run', value: :run .choice name: 'setup (config/initialization)', value: :setup .choice name: 'build', value: :build .choice name: 'publish', value: :publish .choice name: 'install (DragonRuby Versions)', value: :install .choice name: 'Image Helpers [images]', value: :images .choice name: 'Utilities [utils]', value: :utils .choice name: 'gem (Shared Code)', value: :gem .choice name: 'skeleton (Templates)', value: :skeleton .choice name: 'console (pry)', value: :console .choice name: 'exit', value: :exit end rescue TTY::Reader::InputInterrupt exit 0 end |
.prompt ⇒ Object
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(, args) end end |