Class: RemLint::CLI

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

Overview

The remlint command.

Streams are injected rather than assumed, so the whole command is testable without shelling out or capturing $stdout.

Defined Under Namespace

Classes: Options

Constant Summary collapse

EXIT_SUCCESS =
0
EXIT_OFFENSES =
1
EXIT_USAGE =
2
DEFAULT_PATHS =
["."].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out: $stdout, err: $stderr) ⇒ CLI

Returns a new instance of CLI.



34
35
36
37
# File 'lib/remlint/cli.rb', line 34

def initialize(out: $stdout, err: $stderr)
  @out = out
  @err = err
end

Instance Attribute Details

#errObject (readonly)

Returns the value of attribute err.



32
33
34
# File 'lib/remlint/cli.rb', line 32

def err
  @err
end

#outObject (readonly)

Returns the value of attribute out.



32
33
34
# File 'lib/remlint/cli.rb', line 32

def out
  @out
end

Instance Method Details

#call(argv) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/remlint/cli.rb', line 39

def call(argv)
  options = Options.new(
    paths:       [],
    config_path: nil,
    only:        nil,
    format:      Formatter::DEFAULT_TEMPLATE,
    fail_level:  "warning",
  )

  dispatch(parse(argv, options), options)
rescue OptionParser::ParseError => error
  err.puts(error.message)
  EXIT_USAGE
end