Skip to content

Revert "Update swift-argument-parser" #34

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 1 commit into from
Nov 10, 2021
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
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/apple/swift-argument-parser",
"state": {
"branch": null,
"revision": "d2930e8fcf9c33162b9fcc1d522bc975e2d4179b",
"version": "1.0.1"
"revision": "83b23d940471b313427da226196661856f6ba3e0",
"version": "0.4.4"
}
},
{
Expand Down Expand Up @@ -51,7 +51,7 @@
"repositoryURL": "https://github.com/apple/swift-markdown.git",
"state": {
"branch": "main",
"revision": "9a9050095ec93853c0ed01930a9d108d79dc4776",
"revision": "2ba1ed580d18b330f6e89d999b6e09f5f1343fde",
"version": null
}
},
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
.package(url: "https://github.com/apple/swift-nio-ssl.git", .upToNextMinor(from: "2.15.0")),
.package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("main")),
.package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("main")),
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")),
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.4.4")),
.package(name: "SymbolKit", url: "https://github.com/apple/swift-docc-symbolkit", .branch("main")),
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "1.1.2")),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ extension Docc {
"""))
public var diagnosticLevel: String?

// Parse and ignore any unrecognized flags, options, and input.
//
// When we're adding new flags or options to the `convert` command. This behavior allows us to also land
// changes in other tools that pass these values to `docc convert` without coordinating the two releases.

@Argument(parsing: .unconditionalRemaining, help: .hidden)
var unrecognizedArgumentsAndOptions: [String] = []

// MARK: - Computed Properties

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

if !unrecognizedArgumentsAndOptions.isEmpty {
print("note: The following arguments, options, and flags were not recognized and will be ignored: \(unrecognizedArgumentsAndOptions)")
}

if let outputParent = providedOutputURL?.deletingLastPathComponent() {
var isDirectory: ObjCBool = false
guard FileManager.default.fileExists(atPath: outputParent.path, isDirectory: &isDirectory), isDirectory.boolValue else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,21 @@ class ConvertSubcommandTests: XCTestCase {
}
}

func testExtraArgumentsAreIgnored() throws {
setenv(TemplateOption.environmentVariableKey, testTemplateURL.path, 1)

let convertOptions = try Docc.Convert.parse([
testBundleURL.path,
// These are unrecognized
"--extra-option", "\"extra value\"",
"--extra-flag",
// This flag is recognized
"--analyze"
])

XCTAssertEqual(convertOptions.unrecognizedArgumentsAndOptions, ["--extra-option", "\"extra value\"", "--extra-flag"])
}

func testIndex() throws {
setenv(TemplateOption.environmentVariableKey, testTemplateURL.path, 1)

Expand Down