Sha256: 7662f3ed58d5197be6160f6b24b6abd93985235a48048d9d196d19a57f07a842

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require 'thor'

require 'spandx'
require 'spandx/command'
require 'spandx/commands/build'
require 'spandx/commands/scan'

module Spandx
  class CLI < Thor
    Error = Class.new(StandardError)

    desc 'version', 'spandx version'
    def version
      puts "v#{Spandx::VERSION}"
    end
    map %w[--version -v] => :version

    desc 'build', 'Build a package index'
    method_option :help, aliases: '-h', type: :boolean,
                         desc: 'Display usage information'
    method_option :directory, aliases: '-d', type: :string,
                              desc: 'Directory to build index in'
    def build(*)
      if options[:help]
        invoke :help, ['build']
      else
        require_relative 'commands/build'
        Spandx::Commands::Build.new(options).execute
      end
    end

    desc 'scan LOCKFILE', 'Scan a lockfile and list dependencies/licenses'
    method_option :help, aliases: '-h', type: :boolean,
                         desc: 'Display usage information'
    def scan(lockfile = nil)
      if options[:help]
        invoke :help, ['scan']
      else
        Spandx::Commands::Scan.new(lockfile, options).execute
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spandx-0.5.0 lib/spandx/cli.rb
spandx-0.4.1 lib/spandx/cli.rb
spandx-0.4.0 lib/spandx/cli.rb