Class: LintTrappings::Cli

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

Overview

Command line application interface.

Instance Method Summary collapse

Constructor Details

#initialize(application, output) ⇒ Cli

Returns a new instance of Cli.

Parameters:



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

def initialize(application, output)
  @application = application
  @output = output
end

Instance Method Details

#run(args) ⇒ Integer

Parses the given command line arguments and executes appropriate logic based on those arguments.

Parameters:

  • args (Array<String>)

    command line arguments

Returns:

  • (Integer)

    exit status code



20
21
22
23
24
25
26
27
28
29
# File 'lib/lint_trappings/cli.rb', line 20

def run(args)
  options = ArgumentsParser.new(@application).parse(args)
  @application.run(options)
  0 # OK
rescue ScanWarned, ScanFailed => ex
  # Special errors which we don't want to display, but do want their exit status
  ex.exit_status
rescue => ex
  handle_exception(ex)
end