lib/heirloom/cli/destroy.rb in heirloom-0.1.4 vs lib/heirloom/cli/destroy.rb in heirloom-0.2.0
- old
+ new
@@ -1,20 +1,42 @@
module Heirloom
module CLI
class Destroy
- def initialize(args)
- @name = args[:name]
- @id = args[:id]
- @logger = args[:logger]
- @artifact = Artifact.new :name => @name,
- :id => @id,
- :logger => @logger
+ def initialize
+ @opts = read_options
+ @name = @opts[:name]
+ @id = @opts[:id]
+ @logger = HeirloomLogger.new :log_level => @opts[:level]
+ @archive = Archive.new :name => @name,
+ :id => @id,
+ :logger => @logger
end
def destroy
- @artifact.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.", :type => :string,
+ :default => 'info'
+ opt :name, "Name of archive.", :type => :string
+ end
+ end
end
end
end