Class: Oncall::CLI

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

Overview

Manage the processing of command line options

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, options = Oncall.options) ⇒ CLI

Returns a new instance of CLI.



6
7
8
9
# File 'lib/oncall/cli.rb', line 6

def initialize(args, options = Oncall.options)
  @args = args
  @options = options
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



4
5
6
# File 'lib/oncall/cli.rb', line 4

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/oncall/cli.rb', line 4

def options
  @options
end

Class Method Details

.run(args) ⇒ Object



11
12
13
# File 'lib/oncall/cli.rb', line 11

def self.run(args)
  new(args).run
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/oncall/cli.rb', line 15

def run
  parse_cli_options
  load_config_file

  begin
    status = options.runner.run($stderr, $stdout)
  rescue Exception => e
    abort "#{Oncall::SCRIPT}: #{e.message}"
  end

  exit(status) if status.is_a? Integer
end