class SentenceOptions::Command
- SentenceOptions::Command
- Reference
- Object
Defined in:
sentence_options/command.crConstructors
-
.new(name : String, description : String, handler : Proc(Array(String), Bool))
It is assumed that every set of args begins with a Command keyword/name.
Instance Method Summary
- #description : String
-
#handle(args : Array(String)) : Bool
Calls the stored proc with the specified args.
-
#handles_command?(a_command : String) : Bool
Returns a Bool indicating if it can handle the specified command.
- #name : String
Constructor Detail
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"
Instance Method Detail
Calls the stored proc with the specified args. Returns a Bool from the proc indicating if it was successful or not.
Returns a Bool indicating if it can handle the specified command.