Class: Punchlist::Options
- Inherits:
-
Object
- Object
- Punchlist::Options
- Defined in:
- lib/punchlist/options.rb
Overview
Parse command line options
Instance Attribute Summary collapse
-
#default_punchlist_line_regexp ⇒ Object
readonly
Returns the value of attribute default_punchlist_line_regexp.
Instance Method Summary collapse
-
#initialize(args, source_finder_option_parser: SourceFinder::OptionParser.new) ⇒ Options
constructor
A new instance of Options.
- #parse_options ⇒ Object
- #parse_regexp(opts, options) ⇒ Object
- #setup_options(opts) ⇒ Object
Constructor Details
#initialize(args, source_finder_option_parser: SourceFinder::OptionParser.new) ⇒ Options
Returns a new instance of Options.
9 10 11 12 13 |
# File 'lib/punchlist/options.rb', line 9 def initialize(args, source_finder_option_parser: SourceFinder::OptionParser.new) @args = args @source_finder_option_parser = source_finder_option_parser end |
Instance Attribute Details
#default_punchlist_line_regexp ⇒ Object (readonly)
Returns the value of attribute default_punchlist_line_regexp.
7 8 9 |
# File 'lib/punchlist/options.rb', line 7 def default_punchlist_line_regexp @default_punchlist_line_regexp end |
Instance Method Details
#parse_options ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/punchlist/options.rb', line 31 def = nil OptionParser.new do |opts| = (opts) end.parse!(@args) end |
#parse_regexp(opts, options) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/punchlist/options.rb', line 15 def parse_regexp(opts, ) opts.on('-r', '--regexp r', 'Regexp to trigger on - ' \ 'default is XXX|TODO') do |v| [:regexp] = v end end |
#setup_options(opts) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/punchlist/options.rb', line 23 def (opts) = {} opts. = 'Usage: punchlist [options]' @source_finder_option_parser.(opts, ) parse_regexp(opts, ) end |