Module: Jenkins::CLI::Command::InstanceMethods
- Defined in:
- lib/jenkins/cli/command.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#parse(args) ⇒ Object
Set up the instance with command-line arguments.
-
#run ⇒ Object
Run the command.
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
130 131 132 |
# File 'lib/jenkins/cli/command.rb', line 130 def @options end |
Instance Method Details
#parse(args) ⇒ Object
Set up the instance with command-line arguments.
Any arguments from the terminal will be passed to #parse as a whitespace separated list. The default implementation uses Slop to parse this list with the block passed to arguments
Note: If this method returns a falsy value, then the command will not be run.
You can override this instance method if you don’t want to use Slop, or if you want to do some preprocessing before Slop is called. param [Array] args the list of whitespace separated command line arguments return [Object] a truthy value if the parse succeeded and the command can be run.
145 146 147 148 149 150 151 152 153 |
# File 'lib/jenkins/cli/command.rb', line 145 def parse(args) = "#{self.class.command_name} [options] - #{self.class.description}" @options = Slop.new(:help => true, :strict => true, :banner => , &self.class.slop_block) @options.parse(args) rescue Slop::Error => e $stderr.puts e. $stderr.puts @options.help end |
#run ⇒ Object
163 164 165 |
# File 'lib/jenkins/cli/command.rb', line 163 def run self.instance_eval(&self.class.run_block) end |