lib/ronin/ui/cli/model_command.rb in ronin-1.3.0 vs lib/ronin/ui/cli/model_command.rb in ronin-1.4.0.rc1
- old
+ new
@@ -26,12 +26,13 @@
#
# A base-command for querying {Model}s.
#
class ModelCommand < Command
- class_option :database, :type => :string,
- :aliases => '-D'
+ option :database, :type => URI,
+ :flag => '-D',
+ :description => 'The Database URI'
#
# The query options for the command.
#
# @return [Array<Symbol>]
@@ -107,11 +108,12 @@
#
# @api semipublic
#
def self.query_option(name,options={})
query_options << name
- class_option name, options
+
+ return option(name,options)
end
#
# Sets up the {Database}.
#
@@ -120,12 +122,12 @@
# @api semipublic
#
def setup
super
- if self.options[:database]
- Database.repositories[:default] = options[:database]
+ if @database
+ Database.repositories[:default] = @database
end
Database.setup
end
@@ -149,10 +151,10 @@
end
query = self.class.model.all
self.class.each_query_option do |name|
- value = options[name]
+ value = get_param(name).value
# skip unset options
next if value.nil?
if model.properties.named?(name)