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_argumentsinstance method to be added to classes that include this module.
- 
  
    
      #parse_errors  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Defines a parse_errorsinstance 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.
| 134 135 136 | # File 'lib/arg-parser/dsl.rb', line 134 def self.included(base) base.extend(ClassMethods) end | 
Instance Method Details
#args_def ⇒ Definition
Returns The arguments Definition object defined on this class.
| 140 141 142 | # File 'lib/arg-parser/dsl.rb', line 140 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.
| 147 148 149 | # File 'lib/arg-parser/dsl.rb', line 147 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.
| 154 155 156 | # File 'lib/arg-parser/dsl.rb', line 154 def parse_errors args_def.errors end | 
#show_help(*args) ⇒ Object
Outputs detailed help about available arguments.
| 178 179 180 | # File 'lib/arg-parser/dsl.rb', line 178 def show_help(*args) args_def.show_help(*args) end | 
#show_help? ⇒ Boolean
Whether help should be displayed.
| 166 167 168 | # File 'lib/arg-parser/dsl.rb', line 166 def show_help? args_def.show_help? end | 
#show_usage(*args) ⇒ Object
Outputs brief usgae details.
| 172 173 174 | # File 'lib/arg-parser/dsl.rb', line 172 def show_usage(*args) args_def.show_usage(*args) end | 
#show_usage? ⇒ Boolean
Whether usage information should be displayed.
| 160 161 162 | # File 'lib/arg-parser/dsl.rb', line 160 def show_usage? args_def.show_usage? end |