Module: Redmine::Command::InstanceMethods
- Defined in:
- lib/redmine/command.rb
Overview
Special instance methods for Command objects that define a common interface:
-
#options can hold options parsed from command-line switches
-
#call can be invoked to run the command.
Instance Method Summary collapse
-
#call(arguments) ⇒ Object
Override #call to provide your custom logic for a command object.
-
#options ⇒ Object
An generic
optionshash that can be used to store preferences in from command line options, available in both the #usage block and the #call method.
Instance Method Details
#call(arguments) ⇒ Object
Override #call to provide your custom logic for a command object. The #call in this module will be prepended to #call in your own objects, ensuring that when invoked, all options will first be parsed. All non-recognized options will be passed as-is to the original #call method.
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/redmine/command.rb', line 67 def call(arguments) OptionParser.new do |o| o. = 'Usage: ' + self.class.usage_description o.separator '' instance_exec o, &self.class. o.on_tail '-h', '--help', 'Show this message' do puts o exit end end.parse!(arguments) super(arguments) end |
#options ⇒ Object
An generic options hash that can be used to store preferences in from command line options, available in both the #usage block and the #call method.
58 59 60 |
# File 'lib/redmine/command.rb', line 58 def @otions ||= {} end |