Module: ArgParser::DSL
- Defined in:
- lib/arg-parser/dsl.rb
Overview
Namespace for DSL methods that can be imported into a class for defining command-line argument handling.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Hook used to extend the including class with class methods defined in the DSL ClassMethods module.
Instance Method Summary collapse
-
#args_def ⇒ Definition
The arguments Definition object defined on this class.
-
#parse_arguments(args = ARGV) ⇒ Object
Defines a
parse_arguments
instance method to be added to classes that include this module. -
#parse_errors ⇒ Object
Defines a
parse_errors
instance method to be added to classes that include this module. -
#show_help(*args) ⇒ Object
Outputs detailed help about available arguments.
-
#show_help? ⇒ Boolean
Whether help should be displayed.
-
#show_usage(*args) ⇒ Object
Outputs brief usgae details.
-
#show_usage? ⇒ Boolean
Whether usage information should be displayed.
Class Method Details
.included(base) ⇒ Object
Hook used to extend the including class with class methods defined in the DSL ClassMethods module.
169 170 171 172 |
# File 'lib/arg-parser/dsl.rb', line 169 def self.included(base) base.extend(ClassMethods) base.title base.class.name end |
Instance Method Details
#args_def ⇒ Definition
Returns The arguments Definition object defined on this class.
176 177 178 |
# File 'lib/arg-parser/dsl.rb', line 176 def args_def self.class.args_def end |
#parse_arguments(args = ARGV) ⇒ Object
Defines a parse_arguments
instance method to be added to classes that include this module. Uses the args_def
argument definition stored on on the class to define the arguments to parse.
183 184 185 |
# File 'lib/arg-parser/dsl.rb', line 183 def parse_arguments(args = ARGV) args_def.parse(args) end |
#parse_errors ⇒ Object
Defines a parse_errors
instance method to be added to classes that include this module.
190 191 192 |
# File 'lib/arg-parser/dsl.rb', line 190 def parse_errors args_def.errors end |
#show_help(*args) ⇒ Object
Outputs detailed help about available arguments.
214 215 216 |
# File 'lib/arg-parser/dsl.rb', line 214 def show_help(*args) args_def.show_help(*args) end |
#show_help? ⇒ Boolean
Whether help should be displayed.
202 203 204 |
# File 'lib/arg-parser/dsl.rb', line 202 def show_help? args_def.show_help? end |
#show_usage(*args) ⇒ Object
Outputs brief usgae details.
208 209 210 |
# File 'lib/arg-parser/dsl.rb', line 208 def show_usage(*args) args_def.show_usage(*args) end |
#show_usage? ⇒ Boolean
Whether usage information should be displayed.
196 197 198 |
# File 'lib/arg-parser/dsl.rb', line 196 def show_usage? args_def.show_usage? end |