|
11 | 11 |
|
12 | 12 | import XCTest |
13 | 13 | import ArgumentParserTestHelpers |
14 | | -import ArgumentParser |
| 14 | +@testable import ArgumentParser |
15 | 15 |
|
16 | 16 | final class DefaultSubcommandEndToEndTests: XCTestCase { |
17 | 17 | } |
@@ -191,3 +191,28 @@ extension DefaultSubcommandEndToEndTests { |
191 | 191 | XCTAssertThrowsError(try MyCommand.parseAsRoot(["plugin", "--verbose", "my-plugin"])) |
192 | 192 | } |
193 | 193 | } |
| 194 | + |
| 195 | +extension DefaultSubcommandEndToEndTests { |
| 196 | + struct RootWithPassthroughDefault: ParsableCommand { |
| 197 | + static let configuration = CommandConfiguration( |
| 198 | + subcommands: [PassthroughDefault.self], |
| 199 | + defaultSubcommand: PassthroughDefault.self, |
| 200 | + helpNames: [.short, .long, .customLong("help", withSingleDash: true)] |
| 201 | + ) |
| 202 | + } |
| 203 | + |
| 204 | + struct PassthroughDefault: ParsableCommand { |
| 205 | + @Argument(parsing: .captureForPassthrough) |
| 206 | + var remaining: [String] = [] |
| 207 | + } |
| 208 | + |
| 209 | + // Test fix for https://github.com/apple/swift-package-manager/issues/7218 |
| 210 | + func testHelpWithPassthroughDefault() throws { |
| 211 | + AssertParseCommand( |
| 212 | + RootWithPassthroughDefault.self, HelpCommand.self, ["-h"]) { _ in } |
| 213 | + AssertParseCommand( |
| 214 | + RootWithPassthroughDefault.self, HelpCommand.self, ["-help"]) { _ in } |
| 215 | + AssertParseCommand( |
| 216 | + RootWithPassthroughDefault.self, HelpCommand.self, ["--help"]) { _ in } |
| 217 | + } |
| 218 | +} |
0 commit comments