class SentenceOptions::Command

Defined in:

sentence_options/command.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String, description : String, handler : Proc(Array(String), Bool)) #

It is assumed that every set of args begins with a Command keyword/name. The name of this command will be used to determine if it should be used to handle the current set of arguments. The description will be used when generating usage instructions. the handler is a proc that will be passed all the arguments after the one that matched the name.

For example. The following:

my_app tag last item urgent

will be handled by the Command with the name "tag" and its handler will be passed "last item urgent" It is assumed that the handler would have the logic needed to know that "last" is followed by a modifier to tell what kind of thing to choose the last one of, and then tag with "urgent"


[View source]

Instance Method Detail

def description : String #

[View source]
def handle(args : Array(String)) : Bool #

Calls the stored proc with the specified args. Returns a Bool from the proc indicating if it was successful or not.


[View source]
def handles_command?(a_command : String) : Bool #

Returns a Bool indicating if it can handle the specified command.


[View source]
def name : String #

[View source]