Class: Kdep::CLI
- Inherits:
-
Object
- Object
- Kdep::CLI
- Defined in:
- lib/kdep/cli.rb
Constant Summary collapse
- COMMANDS =
{ "render" => Commands::Render, "init" => Commands::Init, "eject" => Commands::Eject, "apply" => Commands::Apply, "diff" => Commands::Diff, "status" => Commands::Status, "build" => Commands::Build, "push" => Commands::Push, "bump" => Commands::Bump, "log" => Commands::Log, "sh" => Commands::Sh, "secrets" => Commands::Secrets, "restart" => Commands::Restart, "scale" => Commands::Scale, "migrate" => Commands::Migrate, "helm-install" => Commands::HelmInstall, "dashboard" => Commands::Dashboard, }.freeze
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
25 26 27 28 |
# File 'lib/kdep/cli.rb', line 25 def initialize(argv) @argv = argv.dup @global_options = {} end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/kdep/cli.rb', line 30 def run global_parser.order!(@argv, into: @global_options) command_name = @argv.shift if command_name.nil? puts global_parser exit 0 end unless COMMANDS.key?(command_name) $stderr.puts "Unknown command: #{command_name}" puts global_parser exit 1 end command_class = COMMANDS[command_name] = {} command_class.option_parser.parse!(@argv, into: ) command_class.new( global_options: @global_options, command_options: , args: @argv ).execute end |