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
Add a help option by default as long as it doesn't conflict with existing options.
This removes the requirement for users to specify [HelpOption] in order to get generated help text.
Add [SuppressDefaultHelpOption] to the type or assembly if you wish to opt-out of this behavior change.
Copy file name to clipboardExpand all lines: docfx_project/docs/concepts/help-text.md
+57-21Lines changed: 57 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,61 +1,97 @@
1
1
# Help Text
2
2
3
3
CommandLineUtils provides API to automatically generate help text for a command line application.
4
-
By default, the help text will only be shown if you indicate that a help option should exit.
5
4
6
-
## Adding a help option
5
+
## Configure the help option
6
+
7
+
### Attribute API
8
+
By default, three options will exist on the command line app that will show help: `-?`, `-h`, and `--help`.
9
+
When users specify one of these, generated help text will display on the command line.
10
+
11
+
```
12
+
> MyApp.exe --help
13
+
14
+
Usage: MyApp.exe [options]
15
+
16
+
Options:
17
+
-?|-h|--help Show help output
18
+
```
19
+
20
+
To customize the flags that can show help text, add an instance of [HelpOptionAttribute](xref:McMaster.Extensions.CommandLineUtils.HelpOptionAttribute) to your model type.
This adds three flags to the command line app that will show help, `-?`, `-h`, and `--help`.
15
63
You can change these flags by calling [`.HelpOption(string template)`](xref:McMaster.Extensions.CommandLineUtils.CommandLineApplication.HelpOption(System.String)) with a template string.
16
64
17
-
```c#
65
+
```csharp
18
66
app.HelpOption("-m|--my-help");
19
67
```
20
68
21
-
When using the **attribute API**, add an instance of [HelpOptionAttribute](xref:McMaster.Extensions.CommandLineUtils.HelpOptionAttribute) to your model type.
22
-
23
-
```c#
24
-
[HelpOption]
25
-
publicclassProgram
26
-
```
27
-
28
-
## Add a help option to all subcommands
69
+
#### Add a help option to all subcommands
29
70
30
71
If you have subcommands on your application, you can make a help option available on all subcommands without
31
72
needing to explicitly add a HelpOption to each subcommand type or object. To do this, set `inherited` to true
32
73
when adding the help option.
33
74
34
-
```c#
75
+
```csharp
35
76
app.HelpOption(inherited: true);
36
77
```
37
78
38
-
```c#
39
-
[HelpOption(Inherited=true)]
40
-
publicclassProgram
41
-
```
42
-
43
79
## Extending help text
44
80
45
81
By default, the help text only includes information about arguments, options, and commands.
46
82
If you would like to provide additional information, you can use the
0 commit comments