Skip to content

Commit e1eba90

Browse files
authored
update use of argument parser to latest API (#6152)
motivation: address warnings from deprecated API changes: use newer API for retreiving unparsed arguments
1 parent f5e1ca3 commit e1eba90

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

Sources/Commands/PackageTools/APIDiff.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct DeprecatedAPIDiff: ParsableCommand {
2424
abstract: "Deprecated - use `swift package diagnose-api-breaking-changes` instead",
2525
shouldDisplay: false)
2626

27-
@Argument(parsing: .unconditionalRemaining)
27+
@Argument(parsing: .captureForPassthrough)
2828
var args: [String] = []
2929

3030
func run() throws {

Sources/Commands/PackageTools/Format.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extension SwiftPackageTool {
2424
@OptionGroup(visibility: .hidden)
2525
var globalOptions: GlobalOptions
2626

27-
@Argument(parsing: .unconditionalRemaining,
27+
@Argument(parsing: .captureForPassthrough,
2828
help: "Pass flag through to the swift-format tool")
2929
var swiftFormatFlags: [String] = []
3030

Sources/Commands/PackageTools/PluginCommand.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct PluginCommand: SwiftCommand {
6565
var command: String = ""
6666

6767
@Argument(
68-
parsing: .unconditionalRemaining,
68+
parsing: .captureForPassthrough,
6969
help: "Arguments to pass to the command plugin"
7070
)
7171
var arguments: [String] = []
@@ -309,13 +309,17 @@ struct PluginCommand: SwiftCommand {
309309

310310
// helper to parse plugin arguments passed after the plugin name
311311
struct PluginArguments: ParsableCommand {
312+
static var configuration: CommandConfiguration {
313+
.init(helpNames: [])
314+
}
315+
312316
@OptionGroup
313317
var globalOptions: GlobalOptions
314318

315319
@OptionGroup()
316320
var pluginOptions: PluginCommand.PluginOptions
317321

318-
@Argument(parsing: .unconditionalRemaining)
322+
@Argument(parsing: .allUnrecognized)
319323
var remaining: [String] = []
320324
}
321325

Sources/Commands/PackageTools/SwiftPackageTool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ extension SwiftPackageTool {
9090
@OptionGroup()
9191
var pluginOptions: PluginCommand.PluginOptions
9292

93-
@Argument(parsing: .unconditionalRemaining)
93+
@Argument(parsing: .captureForPassthrough)
9494
var remaining: [String] = []
9595

9696
func run(_ swiftTool: SwiftTool) throws {

Sources/Commands/SwiftRunTool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct RunToolOptions: ParsableArguments {
8282
var executable: String?
8383

8484
/// The arguments to pass to the executable.
85-
@Argument(parsing: .unconditionalRemaining,
85+
@Argument(parsing: .captureForPassthrough,
8686
help: "The arguments to pass to the executable")
8787
var arguments: [String] = []
8888
}

Tests/CommandsTests/PackageToolTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ final class PackageToolTests: CommandsTestCase {
21372137

21382138
// Check default command arguments
21392139
do {
2140-
let result = try SwiftPMProduct.SwiftPackage.executeProcess(["MyPlugin", "--foo", "--help", "--version", "--verbose"], packagePath: packageDir, env: ["DECLARE_PACKAGE_WRITING_PERMISSION": "1"])
2140+
let result = try SwiftPMProduct.SwiftPackage.executeProcess(["MyPlugin", "--foo", "--help", "--version", "--verbose"], packagePath: packageDir)
21412141
XCTAssertEqual(result.exitStatus, .terminated(code: 0))
21422142
XCTAssertMatch(try result.utf8Output(), .contains("success"))
21432143
XCTAssertEqual(try result.utf8stderrOutput(), "")

0 commit comments

Comments
 (0)