Class: Helmsnap::Runner

Inherits:
Service show all
Defined in:
lib/helmsnap/runner.rb

Instance Method Summary collapse

Methods inherited from Service

call

Constructor Details

#initialize(args) ⇒ Runner

Returns a new instance of Runner.



4
5
6
7
# File 'lib/helmsnap/runner.rb', line 4

def initialize(args)
  super()
  self.args = args.dup
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/helmsnap/runner.rb', line 9

def call
  parser = Helmsnap::ArgsParser.new(args)
  self.options = parser.get_options!
  self.config = Helmsnap::Config.new(options.config_path)

  cmd, *rest = args

  if cmd.nil?
    parser.print_help!("Command not provided.")
  end

  if rest.size.positive?
    parser.print_help!("Too many arguments.")
  end

  case cmd
  when "generate", "gen"
    generate!
  when "check"
    check!
  when "dependencies", "deps"
    setup_deps!
  else
    parser.print_help!("Unknown command: #{cmd}.")
  end
end