-
Notifications
You must be signed in to change notification settings - Fork 0
Creating custom help output
Help is automatically generated by the library in certain scenarios. Help is generated using a formatter. Help generated when:
- No command is found, help will print all available commands.
- Not all arguments are specified, help will print command information.
- Requested by the caller, using any of the reserved keywords.
- When you call
CommandParser.PrintHelp()
Included in the library are two formatters. They are both located in the CommandLineEngine.Formatter namespace.
| Type | Use |
|---|---|
| Console | Outputs help to a console. |
| Text | Outputs help to a StringBuilder (passed in constructor). |
By default, the
Consoleformatter is used if none is specified.
The library uses IHelpFormatter, located in the root CommandLineEngine namespace when it needs to display help.
You can create a class implementing the interface, and simply supply it to the engine.
The interface has a single method to implement with the following parameters:
| Property | Use |
|---|---|
| configuration | Configuration returned from parsing all commands and parameters. |
| command | Single command to output. Note that the command can be null, and you are expected to print help for all commands in this case. |
| operationMessages | Operation messages from parsing commands and validation of arguments. |
You can use base classes in the
CommandLineEngine.Formatters, which include some functionnality for console output, or even derive from the built-in ones.
Need more information or have an idea? Do not hesitate to reach out or submit a pull request.