Sha256: c095df19f94f289310cf8f970fcbefbc81d0fa8bd4b07ecd169a5db4b0597ae7

Contents?: true

Size: 1.9 KB

Versions: 18

Compression:

Stored size: 1.9 KB

Contents

# frozen_string_literal: true

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

      desc 'list', 'List all the inherited decision files'
      def list
        say 'Inherited Decision Files:', :blue
        say_each(decisions.inherited_decisions)
      end

      auditable
      desc 'add DECISION_FILE...', 'Add one or more decision files to the inherited decisions'
      def add(*decision_files)
        assert_some decision_files
        modifying { decision_files.each { |filepath| decisions.inherit_from(filepath) } }
        say "Added #{decision_files.join(', ')} to the inherited decisions"
      end

      auditable
      desc 'add_with_auth URL AUTH_TYPE TOKEN_OR_ENV', 'Add a remote decision file that needs authentication'
      def add_with_auth(*params)
        url, auth_type, token_or_env = params
        auth_info = { 'url' => url, 'authorization' => "#{auth_type} #{token_or_env}" }
        modifying { decisions.add_decision [:inherit_from, auth_info] }
        say "Added #{url} to the inherited decisions"
      end

      auditable
      desc 'remove DECISION_FILE...', 'Remove one or more decision files from the inherited decisions'
      def remove(*decision_files)
        assert_some decision_files
        modifying { decision_files.each { |filepath| decisions.remove_inheritance(filepath) } }
        say "Removed #{decision_files.join(', ')} from the inherited decisions"
      end

      auditable
      desc 'remove_with_auth URL AUTH_TYPE TOKEN_OR_ENV', 'Add a remote decision file that needs authentication'
      def remove_with_auth(*params)
        url, auth_type, token_or_env = params
        auth_info = { 'url' => url, 'authorization' => "#{auth_type} #{token_or_env}" }
        modifying { decisions.remove_inheritance(auth_info) }
        say "Removed #{url} from the inherited decisions"
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
license_finder-6.15.0 lib/license_finder/cli/inherited_decisions.rb
gitlab-license_finder-6.14.2.1 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.14.2 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.14.1 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.13.0 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.12.2 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.12.1 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.12.0 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.11.0 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.10.1 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.10.0 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.9.0 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.8.2 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.8.1 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.8.0 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.7.0 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.6.2 lib/license_finder/cli/inherited_decisions.rb
license_finder-6.6.1 lib/license_finder/cli/inherited_decisions.rb