Skip to content

Commit

Permalink
Add swift-argument-parser (#1)
Browse files Browse the repository at this point in the history
* Add generated schemes to gitignore

* Integrate swift-argument-parser
  • Loading branch information
aidaan authored Oct 14, 2023
1 parent ebb6cea commit f078b9f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
.swiftpm/xcode/xcshareddata/xcschemes/*.xcscheme
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"version" : "0.10.1"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.2.3"
}
},
{
"identity" : "xcconfig",
"kind" : "remoteSourceControl",
Expand Down
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/tuist/XcodeProj", from: "8.15.0"),
.package(url: "https://github.com/mattmassicotte/XCConfig", branch: "main"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.3"),
],
targets: [
.executableTarget(name: "clitool", dependencies: ["XCLinting"]),
.executableTarget(name: "clitool", dependencies: [
"XCLinting",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]),
.target(name: "XCLinting", dependencies: ["XCConfig", "XcodeProj"]),
.testTarget(name: "XCLintTests", dependencies: ["XCLinting"]),

Expand Down
21 changes: 18 additions & 3 deletions Sources/clitool/main.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book
import ArgumentParser

print("Hello, world!")
struct XCLintCommand: ParsableCommand {
static var configuration = CommandConfiguration(commandName: "xclint")

@Flag(
name: .shortAndLong,
help: "Print the version and exit."
)
var version: Bool = false

func run() throws {
if version {
throw CleanExit.message("0.0.1")
}
}
}

XCLintCommand.main()

0 comments on commit f078b9f

Please sign in to comment.