Class: ECG::OptionParser
- Inherits:
-
OptionParser
- Object
- OptionParser
- ECG::OptionParser
- Includes:
- Singleton
- Defined in:
- lib/ecg/option_parser.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#trim_mode ⇒ Object
readonly
Returns the value of attribute trim_mode.
Instance Method Summary collapse
- #banner ⇒ Object
-
#initialize ⇒ OptionParser
constructor
A new instance of OptionParser.
- #parse! ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize ⇒ OptionParser
Returns a new instance of OptionParser.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ecg/option_parser.rb', line 12 def initialize super @args = ARGV.dup @trim_mode = '<>' on_tail( '-t', '--trim-mode MODE', %(Set ERB's trim_mode. Default is "<>".) ) do |v| @trim_mode = v end on_tail('-V', '--version', 'Print version information') do puts ver exit end on_tail('-h', '--help', 'Print this help message', &method(:print_help)) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/ecg/option_parser.rb', line 10 def args @args end |
#trim_mode ⇒ Object (readonly)
Returns the value of attribute trim_mode.
10 11 12 |
# File 'lib/ecg/option_parser.rb', line 10 def trim_mode @trim_mode end |
Instance Method Details
#banner ⇒ Object
30 31 32 |
# File 'lib/ecg/option_parser.rb', line 30 def 'Usage: ecg [config.{json,yaml}] [options]' end |
#parse! ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/ecg/option_parser.rb', line 36 def parse! print_help(false) if @args.empty? super(@args) rescue InvalidOption => e warn e print_help(false) end |
#version ⇒ Object
45 46 47 |
# File 'lib/ecg/option_parser.rb', line 45 def version VERSION end |