Skip to content

Commit e3cb4a5

Browse files
johnbuteJohn Bute
andauthored
swift package --help doesn't show subcommands provided by plugins (#9284)
Modified swift package --help in order to include possible commands provided by command plugins ### Motivation: Fixes #9226 ### Modifications: Overrode --help and -h of swift package command to also include, after printing the help message, the output of swift package plugin --list Added tests to support change too ### Result: After --help message is printed, users will see a new section (whenever needed) called AVAILABLE PLUGIN COMMANDS: ` completion-tool Command to generate shell completions. plugin Invoke a command plugin or perform other actions on command plugins. See 'swift help package <subcommand>' for detailed help. AVAILABLE PLUGIN COMMANDS: benchmark (plugin ‘BenchmarkCommandPlugin’ in package ‘Benchmark’) ` --------- Co-authored-by: John Bute <johnbute@Johns-MacBook-Pro-4.local>
1 parent bb24f66 commit e3cb4a5

29 files changed

+272
-40
lines changed

Sources/Commands/PackageCommands/APIDiff.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import Workspace
2626
struct DeprecatedAPIDiff: ParsableCommand {
2727
static let configuration = CommandConfiguration(commandName: "experimental-api-diff",
2828
abstract: "Deprecated - use `swift package diagnose-api-breaking-changes` instead",
29-
shouldDisplay: false)
29+
shouldDisplay: false,
30+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)])
3031

3132
@Argument(parsing: .captureForPassthrough)
3233
var args: [String] = []
@@ -49,7 +50,9 @@ struct APIDiff: AsyncSwiftCommand {
4950
behavior may be undesirable as the comparison can be slow. \
5051
The `--products` and `--targets` options may be used to restrict the scope of \
5152
the comparison.
52-
""")
53+
""",
54+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
55+
)
5356

5457
@OptionGroup(visibility: .hidden)
5558
var globalOptions: GlobalOptions

Sources/Commands/PackageCommands/AddDependency.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import class PackageModel.Manifest
2727
extension SwiftPackageCommand {
2828
struct AddDependency: SwiftCommand {
2929
package static let configuration = CommandConfiguration(
30-
abstract: "Add a package dependency to the manifest."
30+
abstract: "Add a package dependency to the manifest.",
31+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
3132
)
3233

3334
@Argument(help: "The URL or directory of the package to add.")

Sources/Commands/PackageCommands/AddProduct.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ extension SwiftPackageCommand {
3535
}
3636

3737
package static let configuration = CommandConfiguration(
38-
abstract: "Add a new product to the manifest.")
38+
abstract: "Add a new product to the manifest.",
39+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
40+
)
3941

4042
@OptionGroup(visibility: .hidden)
4143
var globalOptions: GlobalOptions

Sources/Commands/PackageCommands/AddSetting.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ extension SwiftPackageCommand {
3535
}
3636

3737
package static let configuration = CommandConfiguration(
38-
abstract: "Add a new setting to the manifest."
38+
abstract: "Add a new setting to the manifest.",
39+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
3940
)
4041

4142
@OptionGroup(visibility: .hidden)

Sources/Commands/PackageCommands/AddTarget.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ extension SwiftPackageCommand {
4242
}
4343

4444
package static let configuration = CommandConfiguration(
45-
abstract: "Add a new target to the manifest."
45+
abstract: "Add a new target to the manifest.",
46+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
4647
)
4748

4849
@OptionGroup(visibility: .hidden)

Sources/Commands/PackageCommands/AddTargetDependency.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import Workspace
2626
extension SwiftPackageCommand {
2727
struct AddTargetDependency: SwiftCommand {
2828
package static let configuration = CommandConfiguration(
29-
abstract: "Add a new target dependency to the manifest.")
29+
abstract: "Add a new target dependency to the manifest.",
30+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
31+
)
3032

3133
@OptionGroup(visibility: .hidden)
3234
var globalOptions: GlobalOptions

Sources/Commands/PackageCommands/ArchiveSource.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ extension SwiftPackageCommand {
2121
struct ArchiveSource: AsyncSwiftCommand {
2222
static let configuration = CommandConfiguration(
2323
commandName: "archive-source",
24-
abstract: "Create a source archive for the package."
24+
abstract: "Create a source archive for the package.",
25+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
2526
)
2627

2728
@OptionGroup(visibility: .hidden)

Sources/Commands/PackageCommands/AuditBinaryArtifact.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import struct TSCBasic.StringError
2424
struct AuditBinaryArtifact: AsyncSwiftCommand {
2525
static let configuration = CommandConfiguration(
2626
commandName: "experimental-audit-binary-artifact",
27-
abstract: "Audit a static library binary artifact for undefined symbols."
27+
abstract: "Audit a static library binary artifact for undefined symbols.",
28+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
2829
)
2930

3031
@OptionGroup(visibility: .hidden)

Sources/Commands/PackageCommands/CompletionCommand.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ extension SwiftPackageCommand {
2222
struct CompletionCommand: AsyncSwiftCommand {
2323
static let configuration = CommandConfiguration(
2424
commandName: "completion-tool",
25-
abstract: "Command to generate shell completions."
25+
abstract: "Command to generate shell completions.",
26+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
2627
)
2728

2829
enum Mode: String, CaseIterable, ExpressibleByArgument {
@@ -93,4 +94,4 @@ extension SwiftPackageCommand {
9394
}
9495
}
9596
}
96-
}
97+
}

Sources/Commands/PackageCommands/ComputeChecksum.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import struct TSCBasic.SHA256
1919

2020
struct ComputeChecksum: SwiftCommand {
2121
static let configuration = CommandConfiguration(
22-
abstract: "Compute the checksum for a binary artifact.")
22+
abstract: "Compute the checksum for a binary artifact.",
23+
helpNames: [.short, .long, .customLong("help", withSingleDash: true)]
24+
)
2325

2426
@OptionGroup(visibility: .hidden)
2527
var globalOptions: GlobalOptions

0 commit comments

Comments
 (0)