Skip to content

update use of argument parser to latest API #6152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Commands/PackageTools/APIDiff.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct DeprecatedAPIDiff: ParsableCommand {
abstract: "Deprecated - use `swift package diagnose-api-breaking-changes` instead",
shouldDisplay: false)

@Argument(parsing: .unconditionalRemaining)
@Argument(parsing: .captureForPassthrough)
var args: [String] = []

func run() throws {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Commands/PackageTools/Format.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension SwiftPackageTool {
@OptionGroup(visibility: .hidden)
var globalOptions: GlobalOptions

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

Expand Down
8 changes: 6 additions & 2 deletions Sources/Commands/PackageTools/PluginCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct PluginCommand: SwiftCommand {
var command: String = ""

@Argument(
parsing: .unconditionalRemaining,
parsing: .captureForPassthrough,
help: "Arguments to pass to the command plugin"
)
var arguments: [String] = []
Expand Down Expand Up @@ -309,13 +309,17 @@ struct PluginCommand: SwiftCommand {

// helper to parse plugin arguments passed after the plugin name
struct PluginArguments: ParsableCommand {
static var configuration: CommandConfiguration {
.init(helpNames: [])
}

@OptionGroup
var globalOptions: GlobalOptions

@OptionGroup()
var pluginOptions: PluginCommand.PluginOptions

@Argument(parsing: .unconditionalRemaining)
@Argument(parsing: .allUnrecognized)
var remaining: [String] = []
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Commands/PackageTools/SwiftPackageTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ extension SwiftPackageTool {
@OptionGroup()
var pluginOptions: PluginCommand.PluginOptions

@Argument(parsing: .unconditionalRemaining)
@Argument(parsing: .captureForPassthrough)
var remaining: [String] = []

func run(_ swiftTool: SwiftTool) throws {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Commands/SwiftRunTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct RunToolOptions: ParsableArguments {
var executable: String?

/// The arguments to pass to the executable.
@Argument(parsing: .unconditionalRemaining,
@Argument(parsing: .captureForPassthrough,
help: "The arguments to pass to the executable")
var arguments: [String] = []
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/CommandsTests/PackageToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ final class PackageToolTests: CommandsTestCase {

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