lib/rcoli/model.rb in rcoli-0.5.4 vs lib/rcoli/model.rb in rcoli-0.5.5
- old
+ new
@@ -54,11 +54,11 @@
value = true
end
target = self.parent ? :options : :global_options
option.keys.each{|key| result.send(target)[key] = value}
else
- raise InvalidCommand, "#'{arg}' is not a valid option"
+ raise InvalidCommand, "'#{arg}' is not a valid option"
end
else
if (cmd = find_command(arg))
result.command = cmd
cmd.put_default_values(result)
@@ -182,16 +182,29 @@
def execute(args, context)
result = ParsedArgs.new
put_default_values(result)
parse_args(args, result)
if result.command
+
+ # command has to have the action block
action = result.command.get_action
raise "Invalid configuration. Missing action block." unless action
+
+ # enable/disable logging level DEBUG
+ if (result.global_options['debug'])
+ context.instance_exec do
+ @log.level = Logger::DEBUG
+ end
+ end
+
+ # execution of the pre block
context.instance_exec(result.global_options, result.options, result.arguments, &@pre_action) if (@pre_action and !result.command.solitaire?)
+ # execution of the main block
context.instance_exec(result.global_options, result.options, result.arguments, &action)
+ # execution of the post block
context.instance_exec(result.global_options, result.options, result.arguments, &@post_action) if (@post_action and !result.command.solitaire?)
else
- say "Display UI"
+ say "This feature is comming soon. Now you should execute '#{value_of_name} help'"
end
end
def pre(&block)
@pre_action = block
\ No newline at end of file