Class: LicenseFinder::CLI::InheritedDecisions

Inherits:
Base
  • Object
show all
Extended by:
Subcommand
Includes:
MakesDecisions
Defined in:
lib/license_finder/cli/inherited_decisions.rb

Instance Method Summary collapse

Methods included from Subcommand

banner

Methods included from MakesDecisions

included

Instance Method Details

#add(*decision_files) ⇒ Object



17
18
19
20
21
# File 'lib/license_finder/cli/inherited_decisions.rb', line 17

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

#add_with_auth(*params) ⇒ Object



25
26
27
28
29
30
# File 'lib/license_finder/cli/inherited_decisions.rb', line 25

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

#listObject



10
11
12
13
# File 'lib/license_finder/cli/inherited_decisions.rb', line 10

def list
  say 'Inherited Decision Files:', :blue
  say_each(decisions.inherited_decisions)
end

#remove(*decision_files) ⇒ Object



34
35
36
37
38
# File 'lib/license_finder/cli/inherited_decisions.rb', line 34

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

#remove_with_auth(*params) ⇒ Object



42
43
44
45
46
47
# File 'lib/license_finder/cli/inherited_decisions.rb', line 42

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