Sha256: 93a2a16b6a4c5bfdc62e5bb8faf2ada32321a3f88145e376cc88f12d427e1f94

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'thor'
require 'thor/aws'

module Certsweeper
  class CLI < Thor
    include Thor::Aws

    class_option :verbose, type: :boolean, default: false, aliases: [:v]

    desc :list, "List expired and not assigned server certificates"
    def list
      client.list.each do |cert|
        m = cert.server_certificate_metadata
        puts [
          m.server_certificate_name,
          m.expiration
        ].join("\t")
      end
    end

    desc :remove, "Remove expired and not assignd server certificates"
    method_option :certificate_name,  type: :string
    method_option :all,               type: :boolean, default: false
    method_option :dry_run,           type: :boolean, default: false
    def remove
      if options[:all]
        result = client.remove_all
      else
        result = client.remove(options[:certificate_name])
      end

      unless result.empty?
        result.map {|r| puts "remove: #{r}"}
      end
      puts "No remove (dry-run)" if options[:dry_run]
    end

    private

    def client
      @client ||= Client.new options, aws_configuration
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
certsweeper-0.1.1 lib/certsweeper/cli.rb
certsweeper-0.1.0 lib/certsweeper/cli.rb