lib/qualitysmith_extensions/console/command.rb in qualitysmith_extensions-0.0.4 vs lib/qualitysmith_extensions/console/command.rb in qualitysmith_extensions-0.0.5

- old
+ new

@@ -245,11 +245,14 @@ class Console::Command class << self # Starts the command execution. def execute( *args ) - new(global_options, @subcommand_aliases || {}).execute( *args ) + cmd = new() + cmd.instance_variable_set("@global_options", global_options) + cmd.instance_variable_set("@subcommand_aliases", @subcommand_aliases || {}) + cmd.execute( *args ) end # Alias for #execute. alias_method :start, :execute @@ -260,11 +263,11 @@ def global_options @global_options ||= [] end - # This is to be called from your Subcommand module to specify which options should simply be "passed on" to some wrapped command that you will later call. + # This is to be called from your subcommand module to specify which options should simply be "passed on" to some wrapped command that you will later call. # Options that are collected by the option methods that this generates will be stored in @passthrough_options (so remember to append that array to your wrapped command!). # # module Status # Console::Command.pass_through({ # [:_q, :__quiet] => 0, @@ -293,12 +296,10 @@ #p args_for_current_option #puts "in #{method_name}: Passing through #{arity} options: #{@passthrough_options.inspect}" #(why does @passthrough_options show up as nil? even when later on it's *not* nil...) arity end - - # mod.instance_eval %Q{ # def #{method_name}(*args) # @passthrough_options << '#{option_name}' # args_for_current_option = Escape.shell_command(args.slice(0, #{arity})) # @passthrough_options << args_for_current_option unless args_for_current_option == '' @@ -314,17 +315,20 @@ def alias_subcommand(hash) (@subcommand_aliases ||= {}).merge! hash end - end + end # End of class methods + + #----------------------------------------------------------------------------------------------------------------------------- + # Do not let this pass through to # any included module. + # What do you mean? --Tyler - def initialize(global_options, subcommand_aliases) - @global_options, @subcommand_aliases = - global_options, subcommand_aliases + def initialize(global_options=[]) + @global_options = global_options end # Execute the command. def execute( line=nil )