diff --git a/.gitignore b/.gitignore index 0023a53..7589394 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ DerivedData/ .swiftpm/configuration/registries.json .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata .netrc +.swiftpm/xcode/xcshareddata/xcschemes/*.xcscheme diff --git a/Package.resolved b/Package.resolved index f9faee7..852e911 100644 --- a/Package.resolved +++ b/Package.resolved @@ -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", diff --git a/Package.swift b/Package.swift index c1f2f91..f029a8f 100644 --- a/Package.swift +++ b/Package.swift @@ -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"]), diff --git a/Sources/clitool/main.swift b/Sources/clitool/main.swift index 44e20d5..29fe831 100644 --- a/Sources/clitool/main.swift +++ b/Sources/clitool/main.swift @@ -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()