Module: App
- Defined in:
- lib/miniparse/app.rb
Constant Summary collapse
- ERR_NOT_FOUND =
error exit codes
3- ERR_IO =
4
Class Method Summary collapse
- .configure_parser(program_description = nil, &block) ⇒ Object
- .debug(msg) ⇒ Object
- .error(msg) ⇒ Object
- .info(msg) ⇒ Object
- .options ⇒ Object
-
.parser ⇒ Object
lazy parser creation.
-
.reset_parser ⇒ Object
re-initialize the parser (but doesn’t affect the configuration).
- .warn(msg) ⇒ Object
Class Method Details
.configure_parser(program_description = nil, &block) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/miniparse/app.rb', line 33 def self.configure_parser(program_description = nil,&block) reset_parser @program_desc = program_description @do_configure_parser = block nil end |
.debug(msg) ⇒ Object
25 26 27 |
# File 'lib/miniparse/app.rb', line 25 def self.debug(msg) $stdout.puts "debug: #{msg}" if App.[:debug] end |
.error(msg) ⇒ Object
13 14 15 |
# File 'lib/miniparse/app.rb', line 13 def self.error(msg) $stderr.puts "error: #{msg}" end |
.info(msg) ⇒ Object
21 22 23 |
# File 'lib/miniparse/app.rb', line 21 def self.info(msg) $stdout.puts "info: #{msg}" end |
.options ⇒ Object
29 30 31 |
# File 'lib/miniparse/app.rb', line 29 def self. parser. end |
.parser ⇒ Object
lazy parser creation
41 42 43 44 45 46 47 |
# File 'lib/miniparse/app.rb', line 41 def self.parser return @parser if @parser @parser = Miniparse::Parser.new(@program_desc) parser.add_option("--debug", nil, negatable: false) @do_configure_parser.call(parser) parser end |
.reset_parser ⇒ Object
re-initialize the parser (but doesn’t affect the configuration)
50 51 52 |
# File 'lib/miniparse/app.rb', line 50 def self.reset_parser @parser = nil end |
.warn(msg) ⇒ Object
17 18 19 |
# File 'lib/miniparse/app.rb', line 17 def self.warn(msg) $stderr.puts "warning: #{msg}" end |