Class: RunKit::Options::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/run_kit/options/main.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMain

Returns a new instance of Main.



26
# File 'lib/run_kit/options/main.rb', line 26

def initialize = @config = Config.new

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



24
25
26
# File 'lib/run_kit/options/main.rb', line 24

def config
  @config
end

Instance Method Details

#app_nameObject



27
# File 'lib/run_kit/options/main.rb', line 27

def app_name = config.app_name

#parse(argv) ⇒ Object

Parse argv and turn internal parser outcomes into CLI behavior.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/run_kit/options/main.rb', line 30

def parse(argv)
  config.prepare!

  begin
    options = Parser.new(config).parse(argv)
    klass = Data.define(*options.keys)
    klass.new(**options)
  rescue Error => ex
    warn "#{app_name}: #{ex.message}"
    warn "#{app_name}: try '#{app_name} --help' for more information"
    exit_fn(1, error: ex.message)
  rescue HelpRequested, NakedRequested, VersionRequested => ex
    early_exit(ex)
    exit_fn(0)
  end
end