class SentenceOptions::Parser
- SentenceOptions::Parser
- Reference
- Object
Defined in:
sentence_options/parser.crConstructors
-
.new(banner : String)
Creates a new Parser with the specified banner
Instance Method Summary
-
#add_command(command : Command)
Adds a
Command
to the list of commands. - #banner : String
- #commands : Array(SentenceOptions::Command)
-
#parse(args)
parses the arguments (typically ARGV) passed to your app Returns: Bool - false if no
Command
s matched, or no arguments were passed. -
#usage
Retuns a usage string comprised of the baner and the description from all the
Command
objects that have been added.
Constructor Detail
Instance Method Detail
Adds a Command
to the list of commands.
Note: Commands will be compared against arguments
in the order added.
def parse(args)
#
parses the arguments (typically ARGV) passed to your app
Returns: Bool - false if no Command
s matched, or no arguments were passed.
When a Command
matches it returns the return value of its attempt to
handle the args.
successful = my_parser.parse(ARGV)
STDERR.puts my_parser.banner unless successful