Method: LicenseAcceptance::Strategy::Prompt#request

Defined in:
lib/license_acceptance/strategy/prompt.rb

#request(missing_licenses, &persist_callback) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/license_acceptance/strategy/prompt.rb', line 26

def request(missing_licenses, &persist_callback)
  logger.debug("Requesting a license for #{missing_licenses.map(&:id)}")
  c = missing_licenses.size
  s = c > 1 ? "s" : ""

  acceptance_question = "Do you accept the #{c} product license#{s} (#{YES}/no)?"
  output.puts <<~EOM
    #{BORDER}
                Chef License Acceptance

    Before you can continue, #{c} product license#{s}
    must be accepted. View the license at
    https://www.chef.io/end-user-license-agreement/

    License#{s} that need accepting:
      * #{missing_licenses.map(&:pretty_name).join("\n  * ")}

    #{acceptance_question}

  EOM

  if ask(output, c, s, persist_callback)
    output.puts BORDER
    return true
  end

  output.puts <<~EOM

    If you do not accept this license you will
    not be able to use Chef products.

    #{acceptance_question}

  EOM

  answer = ask(output, c, s, persist_callback)
  if answer != "yes"
    output.puts BORDER
  end
  answer
end