Class: CheckPlease::CLI::Parser
- Inherits:
-
Object
- Object
- CheckPlease::CLI::Parser
- Defined in:
- lib/check_please/cli/parser.rb
Instance Method Summary collapse
-
#flags_from_args!(args) ⇒ Object
Unfortunately, OptionParser really wants to use closures.
- #help ⇒ Object
-
#initialize(exe_file_name) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(exe_file_name) ⇒ Parser
Returns a new instance of Parser.
7 8 9 |
# File 'lib/check_please/cli/parser.rb', line 7 def initialize(exe_file_name) @exe_file_name = File.basename(exe_file_name) end |
Instance Method Details
#flags_from_args!(args) ⇒ Object
Unfortunately, OptionParser really wants to use closures. I haven’t yet figured out how to get around this, but at least it’s closing on a local instead of an ivar… progress?
14 15 16 17 18 19 20 21 |
# File 'lib/check_please/cli/parser.rb', line 14 def flags_from_args!(args) flags = Flags.new optparse = option_parser(flags: flags) optparse.parse!(args) # removes recognized flags from `args` return flags rescue OptionParser::InvalidOption, OptionParser::AmbiguousOption => e raise InvalidFlag, e., cause: e end |
#help ⇒ Object
23 24 25 |
# File 'lib/check_please/cli/parser.rb', line 23 def help option_parser.help end |