Skip to content
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

Add swift-argument-parser #1

Merged
merged 2 commits into from
Oct 14, 2023
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
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()
Loading