Class: Ace::Support::Cli::Parser
- Inherits:
-
Object
- Object
- Ace::Support::Cli::Parser
- Defined in:
- lib/ace/support/cli/parser.rb
Instance Method Summary collapse
-
#initialize(command_class, command_name: nil) ⇒ Parser
constructor
A new instance of Parser.
- #parse(args) ⇒ Object
Constructor Details
#initialize(command_class, command_name: nil) ⇒ Parser
Returns a new instance of Parser.
10 11 12 13 |
# File 'lib/ace/support/cli/parser.rb', line 10 def initialize(command_class, command_name: nil) @command_class = command_class @command_name = command_name end |
Instance Method Details
#parse(args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ace/support/cli/parser.rb', line 15 def parse(args) = build_defaults remaining = args.dup if help_requested?(remaining) && rich_help? render_help(remaining) end parser = OptionParser.new parser. = "Usage: #{File.basename($0)} #{command_label} [options]" (parser, ) parser.parse!(remaining) apply_positionals(, remaining) () rescue OptionParser::ParseError => e raise ParseError, (e) rescue ArgumentError => e raise ParseError, e. end |