You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow custom help providers
* Version option will show in help even with a default command
* Reserve `-v` and `--version` as special Spectre.Console command line arguments (nb. breaking change for Spectre.Console users who have a default command with a settings class that uses either of these switches).
* Help writer correctly determines if trailing commands exist and whether to display them as optional or mandatory in the usage statement.
* Ability to control the number of indirect commands to display in the help text when the command itself doesn't have any examples of its own. Defaults to 5 (for backward compatibility) but can be set to any integer or zero to disable completely.
* Significant increase in unit test coverage for the help writer.
* Minor grammatical improvements to website documentation.
Description: "Console applications built with *Spectre.Console.Cli* include automatically generated help command line help."
4
+
---
5
+
6
+
Console applications built with `Spectre.Console.Cli` include automatically generated help which is displayed when `-h` or `--help` has been specified on the command line.
7
+
8
+
The automatically generated help is derived from the configured commands and their command settings.
9
+
10
+
The help is also context aware and tailored depending on what has been specified on the command line before it. For example,
11
+
12
+
1. When `-h` or `--help` appears immediately after the application name (eg. `application.exe --help`), then the help displayed is a high-level summary of the application, including any command line examples and a listing of all possible commands the user can execute.
13
+
14
+
2. When `-h` or `--help` appears immediately after a command has been specified (eg. `application.exe command --help`), then the help displayed is specific to the command and includes information about command specific switches and any default values.
15
+
16
+
`HelpProvider` is the `Spectre.Console` class responsible for determining context and preparing the help text to write to the console. It is an implementation of the public interface `IHelpProvider`.
17
+
18
+
## Custom help providers
19
+
20
+
Whilst it shouldn't be common place to implement your own help provider, it is however possible.
21
+
22
+
You are able to implement your own `IHelpProvider` and configure a `CommandApp` to use that instead of the Spectre.Console help provider.
There is a working [example of a custom help provider](https://github.com/spectreconsole/spectre.console/tree/main/examples/Cli/Help) demonstrating this.
Copy file name to clipboardexpand all lines: docs/input/cli/commandApp.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ For more complex command hierarchical configurations, they can also be composed
43
43
44
44
## Customizing Command Configurations
45
45
46
-
The `Configure` method is also used to change how help for the commands is generated. This configuration will give our command an additional alias of `file-size` and a description to be used when displaying the help. Additional, an example is specified that will be parsed and displayed for users asking for help. Multiple examples can be provided. Commands can also be marked as hidden. With this option they are still executable, but will not be displayed in help screens.
46
+
The `Configure` method is also used to change how help for the commands is generated. This configuration will give our command an additional alias of `file-size` and a description to be used when displaying the help. Additionally, an example is specified that will be parsed and displayed for users asking for help. Multiple examples can be provided. Commands can also be marked as hidden. With this option they are still executable, but will not be displayed in help screens.
Copy file name to clipboardexpand all lines: docs/input/cli/settings.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ This setting file tells `Spectre.Console.Cli` that our command has two parameter
26
26
27
27
## CommandArgument
28
28
29
-
Arguments have a position and a name. The name is not only used for generating help, but its formatting is used to determine whether or not the argument is optional. The name must either be surrounded by square brackets (e.g. `[name]`) or angle brackets (e.g. `<name>`). Angle brackets denote required whereas square brackets denote optional. If neither are specified an exception will be thrown.
29
+
Arguments have a position and a name. The name is not only used for generating help, but its formatting is used to determine whether or not the argument is optional. Angle brackets denote a required argument (e.g. `<name>`) whereas square brackets denote an optional argument (e.g. `[name]`). If neither are specified an exception will be thrown.
30
30
31
31
The position is used for scenarios where there could be more than one argument.
<ExampleDescription>Demonstrates how to extend the built-in Spectre.Console help provider to render a custom banner at the top of the help information.</ExampleDescription>
0 commit comments