class SentenceOptions::Parser

Defined in:

sentence_options/parser.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(banner : String) #

Creates a new Parser with the specified banner


[View source]

Instance Method Detail

def add_command(command : Command) #

Adds a Command to the list of commands. Note: Commands will be compared against arguments in the order added.


[View source]
def banner : String #

[View source]
def commands : Array(SentenceOptions::Command) #

[View source]
def parse(args) #

parses the arguments (typically ARGV) passed to your app Returns: Bool - false if no Commands 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

[View source]
def usage #

Retuns a usage string comprised of the baner and the description from all the Command objects that have been added. typically displayed when --help is called or when no arguments are passed


[View source]