Class: Hako::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/hako/cli.rb

Defined Under Namespace

Classes: Deploy, Oneshot, Remove, ShowYaml, Status

Constant Summary collapse

SUB_COMMANDS =
%w[
  deploy
  oneshot
  show-yaml
  status
  remove
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



19
20
21
22
23
# File 'lib/hako/cli.rb', line 19

def initialize(argv)
  @argv = argv.dup
  @help = false
  parser.order!(@argv)
end

Class Method Details

.start(argv) ⇒ Object



15
16
17
# File 'lib/hako/cli.rb', line 15

def self.start(argv)
  new(argv).run
end

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/hako/cli.rb', line 25

def run
  if @help || @argv.empty?
    puts parser.help
    SUB_COMMANDS.each do |subcommand|
      puts create_subcommand(subcommand).new.parser.help
    end
  else
    create_subcommand(@argv.shift).new.run(@argv)
  end
end