lib/ronin/ui/command_line/commands/add.rb in ronin-0.2.0 vs lib/ronin/ui/command_line/commands/add.rb in ronin-0.2.1
- old
+ new
@@ -25,66 +25,67 @@
require 'ronin/platform/overlay'
module Ronin
module UI
module CommandLine
- class AddCommand < Command
+ module Commands
+ class Add < Command
- command :add
+ def defaults
+ @cache = nil
+ @media = nil
+ @uri = nil
+ end
- def initialize
- @cache = nil
- @media = nil
- @uri = nil
+ def define_options(opts)
+ opts.usage = 'PATH [options]'
- super
- end
+ opts.options do
+ opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
+ @cache = dir
+ end
- def define_options(opts)
- opts.usage = 'PATH [options]'
+ opts.on('-m','--media MEDIA','Spedify the media-type of the overlay') do |media|
+ @media = media
+ end
- opts.options do
- opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
- @cache = dir
- end
+ opts.on('-U','--uri URI','Specify the source URI of the overlay') do |uri|
+ @uri = uri
+ end
- opts.on('-m','--media MEDIA','Spedify the media-type of the overlay') do |media|
- @media = media
+ opts.on('-L','--local','Similiar to: --media local') do
+ @media = :local
+ end
end
- opts.on('-U','--uri URI','Specify the source URI of the overlay') do |uri|
- @uri = uri
- end
+ opts.arguments(
+ 'PATH' => 'Add the overlay located at the specified PATH'
+ )
- opts.on('-L','--local','Similiar to: --media local') do
- @media = :local
- end
+ opts.summary %{
+ Add a local overlay located at the specified PATH to the
+ Overlay cache
+ }
end
- opts.arguments(
- 'PATH' => 'Add the overlay located at the specified PATH'
- )
+ def arguments(*args)
+ unless args.length == 1
+ fail('only one overlay path maybe specified')
+ end
- opts.summary('Add a local overlay located at the specified PATH to the Overlay cache')
- end
+ Platform.load_overlays(@cache) if @cache
- def arguments(*args)
- unless args.length == 1
- fail('only one overlay path maybe specified')
- end
+ overlay_options = {:path => args.first}
- Platform.load_overlays(@cache) if @cache
+ overlay_options[:media] = @media if @media
+ overlay_options[:uri] = @uri if @uri
- overlay_options = {:path => path.first}
-
- overlay_options[:media] = @media if @media
- overlay_options[:uri] = @uri if @uri
-
- Platform.add(overlay_options) do |overlay|
- puts "Overlay #{overlay.name.dump} added."
+ Platform.add(overlay_options) do |overlay|
+ puts "Overlay #{overlay.name.dump} added."
+ end
end
- end
+ end
end
end
end
end