Skip to content

Commit 5156317

Browse files
authored
Support subcommands when querying for help (#620)
1 parent aee45a1 commit 5156317

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Sources/swift-help/main.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ enum Subcommand: String, CaseIterable {
5555
}
5656

5757
struct SwiftHelp: ParsableCommand {
58-
@Argument var topic: HelpTopic = .driver(.interactive)
58+
@Argument(help: "The topic to display help for.")
59+
var topic: HelpTopic = .driver(.interactive)
60+
61+
@Argument(help: "The help subtopics, if applicable.")
62+
var subtopics: [String] = []
5963

6064
@Flag(name: .customLong("show-hidden", withSingleDash: true),
6165
help: "List hidden (unsupported) options")
@@ -89,7 +93,11 @@ struct SwiftHelp: ParsableCommand {
8993
}
9094

9195
// Execute the subcommand with --help.
92-
try exec(path: path.pathString, args: [execName, "--help"])
96+
if subtopics.isEmpty {
97+
try exec(path: path.pathString, args: [execName, "--help"])
98+
} else {
99+
try exec(path: path.pathString, args: [execName, "help"] + subtopics)
100+
}
93101
}
94102
}
95103
}

0 commit comments

Comments
 (0)