Class: Gem::Guardian::CLI

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

Overview

Command-line entry point for gem-guardian. rubocop:disable Metrics/ClassLength, Metrics/ParameterLists

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdout: $stdout, stderr: $stderr, verifier_class: Verifier, lockfile_parser_class: LockfileParser, provenance_verifier_class: ProvenanceVerifier, report_builder_class: ReportBuilder) ⇒ CLI

Returns a new instance of CLI.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gem/guardian/cli.rb', line 17

def initialize(argv, stdout: $stdout, stderr: $stderr, verifier_class: Verifier,
               lockfile_parser_class: LockfileParser, provenance_verifier_class: ProvenanceVerifier,
               report_builder_class: ReportBuilder)
  @argv = argv.dup
  @stdout = stdout
  @stderr = stderr
  @verifier_class = verifier_class
  @lockfile_parser_class = lockfile_parser_class
  @provenance_verifier_class = provenance_verifier_class
  @report_builder_class = report_builder_class
  @result_printer = ResultPrinter.new(stdout:)
end

Class Method Details

.start(argv) ⇒ Object

Starts the CLI with the provided argv.



13
14
15
# File 'lib/gem/guardian/cli.rb', line 13

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

Instance Method Details

#runObject

Dispatches the requested subcommand and returns an exit status.



31
32
33
# File 'lib/gem/guardian/cli.rb', line 31

def run
  dispatch(@argv.shift)
end