Class: CleoQualityReview::CLI

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

Overview

Command-line interface entry point

Constant Summary collapse

SUBCOMMANDS =
{
  "analyze" => :run_analyze,
  "render" => :run_render,
  "publish-pr-review" => :run_publish_pr_review,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdout: $stdout, stderr: $stderr) ⇒ CLI

Returns a new instance of CLI.

Parameters:

  • argv (Array<String>)

    command-line arguments

  • stdout (IO) (defaults to: $stdout)

    standard output stream

  • stderr (IO) (defaults to: $stderr)

    standard error stream



27
28
29
30
31
# File 'lib/cleo_quality_review/cli.rb', line 27

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

Instance Method Details

#runInteger

Execute the CLI

Returns:

  • (Integer)

    exit code (0 for success, 1 for error)



36
37
38
39
40
41
# File 'lib/cleo_quality_review/cli.rb', line 36

def run
  dispatch_command
rescue Error, OptionParser::ParseError, ArgumentError => error
  stderr.puts("check_quality: #{error.message}")
  1
end