Class: Onair::CLI

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

Overview

Errors are rescued here and printed as a single friendly line — no backtraces (--debug re-raises). Returns the process exit code.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(argv) ⇒ Object



9
10
11
# File 'lib/onair/cli.rb', line 9

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

Instance Method Details

#run(argv) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/onair/cli.rb', line 13

def run(argv)
  flags, command = parse(argv)
  case command
  when nil then status(flags)
  when "init" then init(flags)
  else raise Error, "unknown command: #{command} (try `onair --help`)"
  end
  0
rescue OptionParser::ParseError => e
  warn_error(e.message)
  1
rescue Error => e
  raise if flags&.[](:debug)

  warn_error(e.message)
  1
end