Sha256: 3eb4f8ad4aade68437fb19853ac140b20d637508beb5995797d97d7f75acdbcc

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module LicenseFinder
  module CLI
    class Dependencies < Base
      extend Subcommand
      include MakesDecisions

      method_option :approve, type: :boolean, desc: 'Approve the added dependency'
      method_option :homepage, type: :string, desc: 'Source of the added dependency'

      auditable
      desc 'add DEPENDENCY LICENSE VERSION [--homepage=HOMEPAGE] [--approve]', 'Add a dependency that is not managed by a package manager, optionally approving it at the same time'
      def add(name, license, version)
        modifying do
          decisions
            .add_package(name, version, txn)
            .license(name, license, txn)
          decisions.homepage(name, options[:homepage], txn) if options[:homepage]
          decisions.approve(name, txn) if options[:approve]
        end
        if options[:approve]
          printer.say "The #{name} dependency has been added and approved!", :green
        else
          printer.say "The #{name} dependency has been added!", :green
        end
      end

      auditable
      desc 'remove DEPENDENCY', 'Remove a dependency that is not managed by a package manager'
      def remove(name)
        modifying { decisions.remove_package(name, txn) }

        printer.say "The #{name} dependency has been removed.", :green
      end

      desc 'list', 'List manually added dependencies'
      def list
        printer.say 'Manually Added Dependencies:', :blue
        say_each(decisions.packages, &:name)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
license_finder-7.1.0 lib/license_finder/cli/dependencies.rb
license_finder-7.0.1 lib/license_finder/cli/dependencies.rb
license_finder-7.0.0 lib/license_finder/cli/dependencies.rb