class RCoLi::Program
Public Instance Methods
execute(args, context)
click to toggle source
# File lib/rcoli/model.rb, line 204 def execute(args, context) result = ParsedArgs.new put_default_values(result) parse_args(args, result) validate_options(result) if result.command # command has to have the action block action = result.command.get_action raise ApplicationError, "Invalid configuration. Missing action block." unless action # enable/disable logging level DEBUG if (result.options['debug']) context.instance_exec do log.level = Logger::DEBUG end end # enable dev mode if (result.options['dev-mode']) ApplicationContext.instance.devmode = true end if (result.options['debug']) ApplicationContext.instance.debug = true end # execution of the pre block context.instance_exec(result.options, result.arguments, &@pre_action) if (@pre_action and !result.command.value_of_skip_pre) # execution of the main block context.instance_exec(result.options, result.arguments, &action) # execution of the post block context.instance_exec(result.options, result.arguments, &@post_action) if (@post_action and !result.command.value_of_skip_post) else say "This feature is comming soon. You should execute '#{value_of_name} help' now." end end
post(&block)
click to toggle source
# File lib/rcoli/model.rb, line 246 def post(&block) @post_action = block end
pre(&block)
click to toggle source
# File lib/rcoli/model.rb, line 242 def pre(&block) @pre_action = block end