Skip to content

Commit 4c1e060

Browse files
committed
swift-package-migrate: Hide global options
Currently, options that are specific to `swift package migrate` are shown at the very bottom, following all the global options. All anonymous option groups get coalesced into the default "OPTIONS" section, which always comes last. So there is no proper way to hoist subcommand options above all the base/global options other than giving the subcommand option group a title. Using "options" as the title would give us 2 "OPTIONS" sections, whereas a custom title, such as "migrate options", would introduce yet another design inconsistency. Instead, address this by hiding global options, as most other package subcommands do.
1 parent 1a8c516 commit 4c1e060

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Sources/Commands/PackageCommands/Migrate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extension SwiftPackageCommand {
5757
abstract: "Migrate a package or its individual targets to use the given set of features."
5858
)
5959

60-
@OptionGroup()
60+
@OptionGroup(visibility: .hidden)
6161
public var globalOptions: GlobalOptions
6262

6363
@OptionGroup()

Tests/CommandsTests/PackageCommandTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,15 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
21062106
}
21072107
}
21082108

2109+
func testMigrateCommandHelp() async throws {
2110+
let (stdout, _) = try await self.execute(
2111+
["migrate", "--help"],
2112+
)
2113+
2114+
// Global options are hidden.
2115+
XCTAssertNoMatch(stdout, .contains("--package-path"))
2116+
}
2117+
21092118
func testMigrateCommand() async throws {
21102119
try XCTSkipIf(
21112120
!UserToolchain.default.supportesSupportedFeatures,

0 commit comments

Comments
 (0)