class Certman::CLI

Public Instance Methods

delete(domain) click to toggle source
# File lib/certman/cli.rb, line 38
def delete(domain)
  Certman::Client.new(domain, options).delete

  puts 'Done.'
  puts ''
end
request(domain) click to toggle source
# File lib/certman/cli.rb, line 8
def request(domain)
  prompt = TTY::Prompt.new
  pastel = Pastel.new
  client = Certman::Client.new(domain, options)
  prompt_or_notify(client, prompt, pastel)
  rollback_on_interrupt(client, pastel)
  cert_arn = client.request

  puts 'Done.'
  puts ''
  puts "certificate_arn: #{pastel.cyan(cert_arn)}"
  puts ''
end
restore_resources(domain) click to toggle source
# File lib/certman/cli.rb, line 25
def restore_resources(domain)
  prompt = TTY::Prompt.new
  pastel = Pastel.new
  client = Certman::Client.new(domain, options)
  prompt_or_notify(client, prompt, pastel)
  rollback_on_interrupt(client, pastel)
  client.restore_resources

  puts 'Done.'
  puts ''
end

Private Instance Methods

prompt_or_notify(client, prompt, pastel) click to toggle source
# File lib/certman/cli.rb, line 47
def prompt_or_notify(client, prompt, pastel)
  notices = [
    "NOTICE! Your selected region is *#{Aws.config[:region]}*. " \
      "Certman will create a certificate on *#{Aws.config[:region]}*.",
    "NOTICE! Certman has chosen *#{client.region_by_hash}* for S3/SES resources.",
    'NOTICE! When requesting, Certman appends a Receipt Rule to the current Active Receipt Rule Set.'
  ]

  notices.each do |message|
    if options[:non_interactive]
      puts pastel.red(message)
    else
      exit unless prompt.yes?(pastel.red(message << ' OK?'))
    end
  end
end
rollback_on_interrupt(client, pastel) click to toggle source
# File lib/certman/cli.rb, line 64
def rollback_on_interrupt(client, pastel)
  Signal.trap(:INT) do
    puts ''
    puts pastel.red('Rollback start.')
    client.rollback
  end
end