Class: RubyLens::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(arguments) ⇒ CLI

Returns a new instance of CLI.



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

def initialize(arguments)
  @arguments = arguments.dup
end

Instance Method Details

#runObject



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

def run
  arguments = @arguments.dup
  command = arguments.shift
  return print_version if %w[-v --version version].include?(command)
  return print_help(0) if command.nil? || %w[-h --help help].include?(command)
  return generate_report(arguments) if command == "report"
  return generate_showcase(arguments) if command == "showcase"

  $stderr.puts "Unknown command: #{command}"
  print_help(2)
rescue OptionParser::ParseError, Error, Errno::ENOENT => error
  $stderr.puts "rubylens: #{error.message}"
  2
end