Class: Dobby::CLI

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

Overview

The dobby CLI.

Defined Under Namespace

Classes: Finished

Constant Summary collapse

STATUS_SUCCESS =
0
STATUS_WARNING =
1
STATUS_ERROR =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



14
15
16
# File 'lib/dobby/cli.rb', line 14

def initialize
  @options = {}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/dobby/cli.rb', line 12

def options
  @options
end

Instance Method Details

#run(args = ARGV) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dobby/cli.rb', line 18

def run(args = ARGV)
  @options, files = Options.new.parse(args)
  act_on_options
  execute_runner(files)
rescue Finished
  STATUS_SUCCESS
rescue OptionParser::InvalidOption => e
  warn e.message
  warn 'For usage information, use --help'
  STATUS_ERROR
rescue StandardError, SyntaxError, LoadError => e
  warn e.message
  warn e.backtrace
  STATUS_ERROR
end