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
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)