Class: Chelsea::CLI

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

Overview

This class provides an interface to the oss index, gems and deps

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ CLI

rubocop:disable Metrics/ClassLength



32
33
34
35
36
37
# File 'lib/chelsea/cli.rb', line 32

def initialize(opts)
  @opts = opts
  @pastel = Pastel.new
  _validate_arguments
   # Move to formatter
end

Class Method Details

.versionObject

rubocop:enable Metrics/CyclomaticComplexity



62
63
64
# File 'lib/chelsea/cli.rb', line 62

def self.version
  Chelsea::VERSION
end

Instance Method Details

#process!Object

rubocop:disable Metrics/CyclomaticComplexity



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/chelsea/cli.rb', line 40

def process! # rubocop:disable Metrics/AbcSize, Metrics/MethodLength,  Metrics/PerceivedComplexity
  if @opts.config?
    _set_config # move to init
  elsif @opts.clear?
    require_relative 'db'
    Chelsea::DB.new.clear_cache
    puts 'OSS Index cache cleared'
  elsif @opts.file? && @opts.iq?
    dependencies = _process_file_iq
    _submit_sbom(dependencies)
  elsif !@opts.file? && @opts.iq?
    abort 'Missing the --file argument. It is required with the --iq argument.'
  elsif @opts.file?
    _process_file
  elsif @opts.help? # quit on opts.help earlier
    puts _cli_flags # this doesn't exist
  else
    abort 'Missing arguments! Chelsea did nothing. Try providing the --file <Gemfile.lock> argument.'
  end
end