Module: UnimatrixParser::ClassMethods
- Defined in:
- lib/unimatrix_parser.rb
Overview
Class Methods
Instance Method Summary collapse
- #educate_if_empty ⇒ Object
- #option(name, description = "", options = {}) ⇒ Object
- #options ⇒ Object
- #stop_on_unknown ⇒ Object
- #synopsis(synopsis = nil) ⇒ Object
- #with_standard_exception_handling(parser) ⇒ Object
Instance Method Details
#educate_if_empty ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/unimatrix_parser.rb', line 26 def educate_if_empty if ARGV.empty? parser = initialize_parser parser.educate exit end end |
#option(name, description = "", options = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/unimatrix_parser.rb', line 12 def option( name, description = "", = {} ) option = Option.new( name, description, ) @options = [] if @options.nil? @options << option end |
#options ⇒ Object
43 44 45 46 47 48 |
# File 'lib/unimatrix_parser.rb', line 43 def parser = initialize_parser with_standard_exception_handling( parser ) do parser.parse( ARGV ) end end |
#stop_on_unknown ⇒ Object
22 23 24 |
# File 'lib/unimatrix_parser.rb', line 22 def stop_on_unknown @stop_on_unknown = true end |
#synopsis(synopsis = nil) ⇒ Object
18 19 20 |
# File 'lib/unimatrix_parser.rb', line 18 def synopsis( synopsis = nil ) @synopsis = synopsis end |
#with_standard_exception_handling(parser) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/unimatrix_parser.rb', line 34 def with_standard_exception_handling( parser ) yield rescue CommandlineError => error parser.die( error., nil, error.error_code ) rescue HelpNeeded parser.educate exit end |