Skip to content

Commit b30b5e2

Browse files
authored
Adopt the ArgumentParser library for the command-line tools (#2653)
This transitions the Commands tools to use ArgumentParser instead of the TSC parser. The biggest change is that the tools are no longer subclasses of SwiftTool. Instead, each tool conforms to the SwiftCommand protocol, which requires the shared options and creates a SwiftTool instance after parsing.
1 parent 3e7ced6 commit b30b5e2

19 files changed

+1171
-1631
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ find_package(dispatch QUIET)
4343
find_package(Foundation QUIET)
4444

4545
find_package(Yams CONFIG REQUIRED)
46+
find_package(ArgumentParser CONFIG REQUIRED)
4647
find_package(SwiftDriver CONFIG REQUIRED)
4748

4849
add_subdirectory(Sources)

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ let package = Package(
147147
.target(
148148
/** High-level commands */
149149
name: "Commands",
150-
dependencies: ["SwiftToolsSupport-auto", "Build", "PackageGraph", "SourceControl", "Xcodeproj", "Workspace", "XCBuildSupport"]),
150+
dependencies: ["SwiftToolsSupport-auto", "Build", "PackageGraph", "SourceControl", "Xcodeproj", "Workspace", "XCBuildSupport", "ArgumentParser"]),
151151
.target(
152152
/** The main executable provided by SwiftPM */
153153
name: "swift-package",
@@ -263,11 +263,13 @@ if ProcessInfo.processInfo.environment["SWIFTPM_LLBUILD_FWK"] == nil {
263263
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
264264
package.dependencies += [
265265
.package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("master")),
266+
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.3.0")),
266267
.package(url: "https://github.com/apple/swift-driver.git", .branch("master")),
267268
]
268269
} else {
269270
package.dependencies += [
270271
.package(path: "./swift-tools-support-core"),
272+
.package(path: "../swift-argument-parser"),
271273
.package(path: "../swift-driver"),
272274
]
273275
}

Sources/Commands/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
add_library(Commands
1010
APIDigester.swift
11-
Completions+bash.swift
12-
Completions+zsh.swift
1311
Describe.swift
1412
Error.swift
1513
GenerateLinuxMain.swift
@@ -24,6 +22,7 @@ add_library(Commands
2422
SymbolGraphExtract.swift
2523
WatchmanHelper.swift)
2624
target_link_libraries(Commands PUBLIC
25+
ArgumentParser
2726
Build
2827
PackageGraph
2928
SourceControl

Sources/Commands/Completions+bash.swift

Lines changed: 0 additions & 114 deletions
This file was deleted.

Sources/Commands/Completions+zsh.swift

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)