Skip to content

Commit bf9bdfb

Browse files
authored
Revert "Update swift-argument-parser (#32)" (#34)
This reverts commit a8a9b4a.
1 parent a8a9b4a commit bf9bdfb

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

Package.resolved

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"repositoryURL": "https://github.com/apple/swift-argument-parser",
77
"state": {
88
"branch": null,
9-
"revision": "d2930e8fcf9c33162b9fcc1d522bc975e2d4179b",
10-
"version": "1.0.1"
9+
"revision": "83b23d940471b313427da226196661856f6ba3e0",
10+
"version": "0.4.4"
1111
}
1212
},
1313
{
@@ -51,7 +51,7 @@
5151
"repositoryURL": "https://github.com/apple/swift-markdown.git",
5252
"state": {
5353
"branch": "main",
54-
"revision": "9a9050095ec93853c0ed01930a9d108d79dc4776",
54+
"revision": "2ba1ed580d18b330f6e89d999b6e09f5f1343fde",
5555
"version": null
5656
}
5757
},

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
114114
.package(url: "https://github.com/apple/swift-nio-ssl.git", .upToNextMinor(from: "2.15.0")),
115115
.package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("main")),
116116
.package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("main")),
117-
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")),
117+
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.4.4")),
118118
.package(name: "SymbolKit", url: "https://github.com/apple/swift-docc-symbolkit", .branch("main")),
119119
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "1.1.2")),
120120
]

Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/Convert.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ extension Docc {
185185
"""))
186186
public var diagnosticLevel: String?
187187

188+
// Parse and ignore any unrecognized flags, options, and input.
189+
//
190+
// When we're adding new flags or options to the `convert` command. This behavior allows us to also land
191+
// changes in other tools that pass these values to `docc convert` without coordinating the two releases.
192+
193+
@Argument(parsing: .unconditionalRemaining, help: .hidden)
194+
var unrecognizedArgumentsAndOptions: [String] = []
195+
188196
// MARK: - Computed Properties
189197

190198
/// The path to the directory that all build output should be placed in.
@@ -214,6 +222,10 @@ extension Docc {
214222
""")
215223
}
216224

225+
if !unrecognizedArgumentsAndOptions.isEmpty {
226+
print("note: The following arguments, options, and flags were not recognized and will be ignored: \(unrecognizedArgumentsAndOptions)")
227+
}
228+
217229
if let outputParent = providedOutputURL?.deletingLastPathComponent() {
218230
var isDirectory: ObjCBool = false
219231
guard FileManager.default.fileExists(atPath: outputParent.path, isDirectory: &isDirectory), isDirectory.boolValue else {

Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,21 @@ class ConvertSubcommandTests: XCTestCase {
289289
}
290290
}
291291

292+
func testExtraArgumentsAreIgnored() throws {
293+
setenv(TemplateOption.environmentVariableKey, testTemplateURL.path, 1)
294+
295+
let convertOptions = try Docc.Convert.parse([
296+
testBundleURL.path,
297+
// These are unrecognized
298+
"--extra-option", "\"extra value\"",
299+
"--extra-flag",
300+
// This flag is recognized
301+
"--analyze"
302+
])
303+
304+
XCTAssertEqual(convertOptions.unrecognizedArgumentsAndOptions, ["--extra-option", "\"extra value\"", "--extra-flag"])
305+
}
306+
292307
func testIndex() throws {
293308
setenv(TemplateOption.environmentVariableKey, testTemplateURL.path, 1)
294309

0 commit comments

Comments
 (0)