<commit_before>
module Kontena::Cli::Certificate
  class RegisterCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions


    parameter "EMAIL", "Email to register"

    def execute
      require_api_url
      token = require_token

      data = {email: email}
      response = client(token).post("certificates/#{current_grid}/register", data)
      puts 'Email registered to LetsEncrypt'
    end
  end
end<commit_msg>Add LE TOS agreement on register command (#2754)<commit_after>
module Kontena::Cli::Certificate
  class RegisterCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions


    parameter "EMAIL", "Email to register"

    option '--agree-tos', :flag, "Automatically agree on Let's Encrypt Terms of Service"

    def execute
      require_api_url
      token = require_token

      data = {email: email}

      if self.agree_tos? || ask_continue
        response = client(token).post("certificates/#{current_grid}/register", data)
        puts 'Email registered to LetsEncrypt'
      end
    end

    def ask_continue
      puts "By registering, you agree on Let's Encrypt Terms of Service: https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf"
      exit_with_error "Registration canceled!" unless prompt.yes?("Continue?")
      true
    end
  end
end
{'fraction_non_alphanumeric': 0.09911894273127753, 'fraction_numerical': 0.00881057268722467, 'mean_word_length': 3.425324675324675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6810208', 'n_tokens_mistral': 416, 'n_tokens_neox': 395, 'n_words': 110}