lib/ronin/ui/command_line/commands/add.rb in ronin-0.1.4 vs lib/ronin/ui/command_line/commands/add.rb in ronin-0.2.0

- old
+ new

@@ -20,23 +20,35 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #++ # require 'ronin/ui/command_line/command' -require 'ronin/cache/overlay' +require 'ronin/platform/overlay' module Ronin module UI module CommandLine class AddCommand < Command command :add + def initialize + @cache = nil + @media = nil + @uri = nil + + super + end + def define_options(opts) opts.usage = 'PATH [options]' opts.options do + opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir| + @cache = dir + end + opts.on('-m','--media MEDIA','Spedify the media-type of the overlay') do |media| @media = media end opts.on('-U','--uri URI','Specify the source URI of the overlay') do |uri| @@ -58,15 +70,18 @@ def arguments(*args) unless args.length == 1 fail('only one overlay path maybe specified') end - path = args.first + Platform.load_overlays(@cache) if @cache - Cache::Overlay.save_cache do - Cache::Overlay.add(path,@media,@uri) do |overlay| - puts "Overlay #{overlay.name.dump} added." - end + 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." end end end end