module Drudge::Parsers::ArgumentParser
Public Instance Methods
collated_arguments()
click to toggle source
a parser that collates the results of argument parsing
# File lib/drudge/parsers.rb, line 73 def collated_arguments self.mapr do |results| args = results.to_a.reduce({args: []}) do |a, (kind, value, *rest)| case kind when :arg a[:args] << value end a end Single(args) end end
parse(argv)
click to toggle source
tokenizes and parses an array of arguments
# File lib/drudge/parsers.rb, line 55 def parse(argv) self[tokenize(argv)] end
parse!(argv)
click to toggle source
tokenizes and parses an array of arguments, returning the parsed result. Raises an error if the parse fails
# File lib/drudge/parsers.rb, line 61 def parse!(argv) input = tokenize(argv) res = self[input] if res.success? res.result else raise ParseError.new(input, res.remaining), res.message end end