Sha256: d023648be317556ac6740ced2410c08baf94671afba34451828f377d2394f2a8

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

module Heirloom
  module CLI
    class Destroy

      def initialize
        @opts = read_options
        @logger = HeirloomLogger.new :log_level => @opts[:level]
        exit 1 unless CLI::Shared.valid_options? :provided => @opts,
                                                 :required => [:name, :id],
                                                 :logger   => @logger
        @name = @opts[:name]
        @id = @opts[:id]
        @archive = Archive.new :name   => @name,
                               :id     => @id,
                               :logger => @logger
      end
      
      def destroy
        @archive.destroy
      end

      private

      def read_options
        Trollop::options do
          version Heirloom::VERSION
          banner <<-EOS

Destroy an archive.

Usage:

heirloom destroy -n NAME -i ID [-l LOG_LEVEL]

EOS
          opt :help, "Display Help"
          opt :id, "ID of the archive to display.", :type => :string
          opt :level, "Log level [debug|info|warn|error].", :type    => :string,
                                                            :default => 'info'
          opt :name, "Name of archive.", :type => :string
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
heirloom-0.3.1 lib/heirloom/cli/destroy.rb
heirloom-0.3.0 lib/heirloom/cli/destroy.rb
heirloom-0.3.0.rc1 lib/heirloom/cli/destroy.rb