Class: Rubycom::ArgParse::ArgParser

Inherits:
Parslet::Parser
  • Object
show all
Defined in:
lib/rubycom/arg_parse.rb

Overview

Comprised of grammar rules which determine whether a given string is an argument, option, or flag. Calling #parse with a String on an instance of this class will return a nested hash structure which identifies the patterns recognized in the given string. In order to use this parser on a command line argument array, it may be necessary to pre-join optional argument keys to their values such that each item in the array is either a complete argument, complete optional-argument, or a flag.

Example:

Rubycom::ArgParse::ArgParser.new.parse("-test_arg = test")
=> {:opt=>{:key=>"-test_arg"@0, :sep=>" = "@9, :val=>"test"@12}}