class Licensed::CLI

Public Class Methods

exit_on_failure?() click to toggle source

If an error occurs (e.g. a missing command or argument), exit 1.

# File lib/licensed/cli.rb, line 97
def self.exit_on_failure?
  true
end

Public Instance Methods

cache() click to toggle source
# File lib/licensed/cli.rb, line 17
def cache
  run Licensed::Commands::Cache.new(config: config),
      force: options[:force], sources: options[:sources], reporter: options[:format]
end
env() click to toggle source
# File lib/licensed/cli.rb, line 72
def env
  run Licensed::Commands::Environment.new(config: config), reporter: options[:format]
end
list() click to toggle source
# File lib/licensed/cli.rb, line 45
def list
  run Licensed::Commands::List.new(config: config), sources: options[:sources], reporter: options[:format], licenses: options[:licenses]
end
migrate() click to toggle source
# File lib/licensed/cli.rb, line 81
def migrate
  shell = Thor::Base.shell.new
  case options["from"]
  when "v1"
    Licensed::Migrations::V2.migrate(options["config"])
  when "v2"
    shell.say "No configuration or cached file migration needed."
    shell.say "Please see the documentation at https://github.com/github/licensed/tree/master/docs/migrations/v3.md for details."
  else
    shell.say "Unrecognized option from=#{options["from"]}", :red
    CLI.command_help(shell, "migrate")
    exit 1
  end
end
notices() click to toggle source
# File lib/licensed/cli.rb, line 56
def notices
  run Licensed::Commands::Notices.new(config: config), sources: options[:sources], computed: options[:computed]
end
status() click to toggle source
# File lib/licensed/cli.rb, line 32
def status
  run Licensed::Commands::Status.new(config: config), sources: options[:sources], reporter: options[:format], data_source: options[:data_source]
end
version() click to toggle source
# File lib/licensed/cli.rb, line 63
def version
  puts Licensed::VERSION
end

Private Instance Methods

config() click to toggle source

Returns a configuration object for the CLI command

# File lib/licensed/cli.rb, line 104
def config
  @config ||= Configuration.load_from(config_path)
end
config_path() click to toggle source

Returns a config path from the CLI if set. Defaults to the current directory if CLI option is not set

# File lib/licensed/cli.rb, line 110
def config_path
  options["config"] || Dir.pwd
end
run(command, **args) click to toggle source
# File lib/licensed/cli.rb, line 114
def run(command, **args)
  exit command.run(**args)
end