Sha256: 65fd40b374ee5169c7f9eeea33b99ec82d1f17cef48c087a5fd293d021788c40

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true
require "licensed"
require "thor"

module Licensed
  class CLI < Thor

    desc "cache", "Cache the licenses of dependencies"
    method_option :force, type: :boolean,
      desc: "Overwrite licenses even if version has not changed."
    method_option :offline, type: :boolean,
      desc: "This option is deprecated and will be removed in the next major release."
    method_option :config, aliases: "-c", type: :string,
      desc: "Path to licensed configuration file"
    def cache
      run Licensed::Command::Cache.new(config), force: options[:force]
    end

    desc "status", "Check status of dependencies' cached licenses"
    method_option :config, aliases: "-c", type: :string,
      desc: "Path to licensed configuration file"
    def status
      run Licensed::Command::Status.new(config)
    end

    desc "list", "List dependencies"
    method_option :config, aliases: "-c", type: :string,
      desc: "Path to licensed configuration file"
    def list
      run Licensed::Command::List.new(config)
    end

    map "-v" => :version
    map "--version" => :version
    desc "version", "Show Installed Version of Licensed, [-v, --version]"
    def version
      run Licensed::Command::Version.new
    end

    private

    # Returns a configuration object for the CLI command
    def config
      @config ||= Configuration.load_from(config_path)
    end

    # Returns a config path from the CLI if set.
    # Defaults to the current directory if CLI option is not set
    def config_path
      options["config"] || Dir.pwd
    end

    def run(command, *args)
      command.run(*args)
      exit command.success?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
licensed-1.5.1 lib/licensed/cli.rb