Module: Climate::Script
- Includes:
- ParsingMethods
- Defined in:
- lib/climate/script.rb
Overview
Module that you can extend any object with to turn it in to a climate script. See the readme for intended usage, but follows the same pattern as the command, with the exception that it does not allow subcommands
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#leftovers ⇒ Object
readonly
Returns the value of attribute leftovers.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #ancestors ⇒ Object
-
#description(string = nil) ⇒ Object
Set the description for this script.
- #has_subcommands? ⇒ Boolean
- #name ⇒ Object
- #parse_argv ⇒ Object
Methods included from ParsingMethods
#arg, #check_arguments, #cli_arguments, #cli_options, #has_arguments?, #has_options?, #help_banner, #opt, #parse, #stop_on, #trollop_parser
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
35 36 37 |
# File 'lib/climate/script.rb', line 35 def arguments @arguments end |
#leftovers ⇒ Object (readonly)
Returns the value of attribute leftovers.
35 36 37 |
# File 'lib/climate/script.rb', line 35 def leftovers @leftovers end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
35 36 37 |
# File 'lib/climate/script.rb', line 35 def end |
Class Method Details
.extended(othermodule) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/climate/script.rb', line 8 def self.extended(othermodule) if @included.nil? @included = true at_exit do Climate.with_standard_exception_handling do othermodule.send(:parse_argv) othermodule.send(:run) end end end end |
Instance Method Details
#ancestors ⇒ Object
37 |
# File 'lib/climate/script.rb', line 37 def ancestors ; [self] ; end |
#description(string = nil) ⇒ Object
Set the description for this script
23 24 25 26 27 28 29 |
# File 'lib/climate/script.rb', line 23 def description(string=nil) if string.nil? @description else @description = string end end |
#has_subcommands? ⇒ Boolean
40 |
# File 'lib/climate/script.rb', line 40 def has_subcommands? ; false ; end |
#name ⇒ Object
38 |
# File 'lib/climate/script.rb', line 38 def name ; File.basename($CLIMATE_PROGRAM_NAME || $PROGRAM_NAME) ; end |
#parse_argv ⇒ Object
31 32 33 |
# File 'lib/climate/script.rb', line 31 def parse_argv @arguments, , @leftovers = self.parse(ARGV) end |