Class: RCoLi::Program
Instance Attribute Summary
#parent
Instance Method Summary
collapse
#action, #command, #commands, #find_command, #flag, #get_action, #options, #parse_args, #put_default_values, #switch, #validate_options
Methods included from Help
#help, #template
Instance Method Details
#execute(args, context) ⇒ Object
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
# File 'lib/rcoli/model.rb', line 200
def execute(args, context)
result = ParsedArgs.new
put_default_values(result)
parse_args(args, result)
validate_options(result, :global_options)
if result.command
action = result.command.get_action
raise ApplicationError, "Invalid configuration. Missing action block." unless action
if (result.global_options['debug'])
context.instance_exec do
log.level = Logger::DEBUG
end
end
if (result.global_options['dev-mode'])
ApplicationContext.instance.devmode = true
end
context.instance_exec(result.global_options, result.options, result.arguments, &@pre_action) if (@pre_action and !result.command.value_of_skip_pre)
context.instance_exec(result.global_options, result.options, result.arguments, &action)
context.instance_exec(result.global_options, 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) ⇒ Object
238
239
240
|
# File 'lib/rcoli/model.rb', line 238
def post(&block)
@post_action = block
end
|
#pre(&block) ⇒ Object
234
235
236
|
# File 'lib/rcoli/model.rb', line 234
def pre(&block)
@pre_action = block
end
|