Skip to content

Commit bf3865c

Browse files
author
Miguel Perez
committed
Added documentation
1 parent 26905bf commit bf3865c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Documentation/04 Customizing Help.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,45 @@ struct Example: ParsableCommand {
193193
var experimentalEnableWidgets: Bool
194194
}
195195
```
196+
## Excluding Super Commands from printing their help
196197

198+
When printing help for a subcommand you may find it desirable to exclude any help that comes from a super command. You can prevent the help for super commands by adding `includeSuperCommandInHelp = false` to your struct.
199+
200+
```swift
201+
public struct Foo: ParsableCommand {
202+
public static var configuration = CommandConfiguration(
203+
commandName: "foo",
204+
subcommands: [Bar.self])
205+
206+
@OptionGroup()
207+
var fooOptions: FooToolOptions
208+
209+
public init() {}
210+
}
211+
212+
extension Foo {
213+
struct Bar: ParsableCommand {
214+
static let configuration = CommandConfiguration(
215+
abstract: "Make Bar")
216+
217+
static let includeSuperCommandInHelp = false
218+
219+
@Option(name: .customLong("name"), help: "Provide custom name")
220+
var barName: String?
221+
}
222+
}
223+
```
224+
```
225+
$ foo bar --help
226+
OVERVIEW: Make Bar
227+
228+
USAGE: foo bar [--name <name>]
229+
230+
OPTIONS:
231+
--name <name> Provide custom name
232+
--version Show the version.
233+
-help, -h, --help Show help information.
234+
```
197235
## Generating Help Text Programmatically
198236

199237
The help screen is automatically shown to users when they call your command with the help flag. You can generate the same text from within your program by calling the `helpMessage()` method.

0 commit comments

Comments
 (0)