lib/spandx/cli/main.rb in spandx-0.16.1 vs lib/spandx/cli/main.rb in spandx-0.17.0

- old
+ new

@@ -10,19 +10,15 @@ method_option :logfile, aliases: '-l', type: :string, desc: 'Path to a logfile', default: '/dev/null' method_option :format, aliases: '-f', type: :string, desc: 'Format of report. (table, csv, json)', default: 'table' method_option :pull, aliases: '-p', type: :boolean, desc: 'Pull the latest cache before the scan', default: false method_option :require, aliases: '-r', type: :string, desc: 'Causes spandx to load the library using require.', default: nil def scan(lockfile = Pathname.pwd) - if options[:help] - invoke :help, ['scan'] - else - Oj.default_options = { mode: :strict } - Spandx.airgap = options[:airgap] - Spandx.logger = Logger.new(options[:logfile]) - pull if options[:pull] - Spandx::Cli::Commands::Scan.new(lockfile, options).execute - end + return invoke :help, ['scan'] if options[:help] + + prepare(options) + pull if options[:pull] + Spandx::Cli::Commands::Scan.new(lockfile, options).execute end desc 'pull', 'Pull the latest offline cache' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def pull(*) @@ -50,8 +46,16 @@ desc 'version', 'spandx version' def version puts "v#{Spandx::VERSION}" end map %w[--version -v] => :version + + private + + def prepare(options) + Oj.default_options = { mode: :strict } + Spandx.airgap = options[:airgap] + Spandx.logger = Logger.new(options[:logfile]) + end end end end