-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Hello.
I am using this cli in an embedded c++ project, and it's pretty cool.
I found this getopt port and I could eventually use it by iterating on the args.
When in it comes to help, it would be great to have the possibilty to pass a string documenting the CLI args and options.
This way say we have a short description to summarize the purpose of the command, and a long one that is printed when we call help on this command.
Namely
#define LED_CMD_SYNTAX "\
led [-p <led_id>] [<arg>]\n\
\t -p <led_id>: led id, must be 0, 1 or 2. defaults to 0.\n\
\t <arg>: toggle,on or off. defaults to toggle\
"
CliCommandBinding led_binding = {
.name = "led",
.help= "Led manipulation command", // this is the short help
.syntax=LED_CMD_SYNTAX, // this is the long help, can be NULL if not used
.tokenizeArgs = true,
.context = NULL,
.binding = onLed
}; Expected output:
$ help
* help
Print list of commands
* clear
Clears the console
* led
Led manipulation command$ help led
* led
Led manipulation command.
Syntax:
led [-p <led_id>] [<arg>]
-p <led_id>: led id, must be 0, 1 or 2. defaults to 0.
<arg>: toggle,on or off. defaults to toggleMetadata
Metadata
Assignees
Labels
No labels