diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..ce7f2b4 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +5.2.2 diff --git a/LICENSE.md b/LICENSE.md index 63e59a7..2741fb2 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -The MIT License (MIT) +# The MIT License (MIT) Copyright ©️ 2020 Ben Chatelain diff --git a/Makefile b/Makefile index 2eb1d1e..395a2e6 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,14 @@ # # Makefile -# Makefile-swift +# SwiftCLI # -# https://github.com/phatblat/Makefile-swift ################################################################################ # # Variables # -CMD_NAME = signpass +CMD_NAME = swiftcli SHELL = /bin/sh # trunk diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..0ba1aa4 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,34 @@ +{ + "object": { + "pins": [ + { + "package": "Nimble", + "repositoryURL": "https://github.com/Quick/Nimble", + "state": { + "branch": null, + "revision": "72f5a90d573f7f7d70aa6b8ad84b3e1e02eabb4d", + "version": "8.0.9" + } + }, + { + "package": "Quick", + "repositoryURL": "https://github.com/Quick/Quick", + "state": { + "branch": null, + "revision": "33682c2f6230c60614861dfc61df267e11a1602f", + "version": "2.2.0" + } + }, + { + "package": "swift-argument-parser", + "repositoryURL": "https://github.com/apple/swift-argument-parser", + "state": { + "branch": null, + "revision": "223d62adc52d51669ae2ee19bdb8b7d9fd6fcd9c", + "version": "0.0.6" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..aa5c975 --- /dev/null +++ b/Package.swift @@ -0,0 +1,40 @@ +// swift-tools-version:5.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. +// https://github.com/apple/swift-package-manager/blob/master/Documentation/PackageDescription.md + +import PackageDescription + +let package = Package( + name: "SwiftCLI", + platforms: [ + .macOS(.v10_15), + ], + products: [ + .executable( + name: "swiftcli", + targets: ["swiftcli"]), + .library( + name: "SwiftCLIKit", + type: .dynamic, + targets: ["SwiftCLIKit"]), + ], + dependencies: [ + .package(url: "https://github.com/apple/swift-argument-parser", .upToNextMajor(from: "0.0.1")), + .package(url: "https://github.com/Quick/Quick", .upToNextMajor(from: "2.2.0")), + .package(url: "https://github.com/Quick/Nimble", .upToNextMajor(from: "8.0.9")), + ], + targets: [ + .target( + name: "swiftcli", + dependencies: ["SwiftCLIKit"]), + .target( + name: "SwiftCLIKit", + dependencies: [ + .product(name: "ArgumentParser", package: "swift-argument-parser") + ]), + .testTarget( + name: "SwiftCLIKitTests", + dependencies: ["SwiftCLIKit", "Quick", "Nimble"]), + ], + swiftLanguageVersions: [.v5] +) diff --git a/README.md b/README.md index 8a0e851..66e6267 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ -# Makefile-swift +# SwiftCLI -A template `Makefile` for Swift projects using the Swift Package Manager. -Based on Rob Allen's +A template for Swift projects using the Swift Package Manager. Includes 3 targets: + +- `swiftcli`: an executable +- `SwiftCLIKit`: a library/framework to hold all logic +- `SwiftCLIKitTests`: tests for the library + +The reason for putting all logic in the library is because an executable target +is not a bundle and thus Xcode can't run tests against it. + +`Makefile` is based on Rob Allen's [Cross-platform Makefile for Swift](https://akrabat.com/cross-platform-makefile-for-swift/) ## 📄 License diff --git a/Resources/sample_file.txt b/Resources/sample_file.txt new file mode 100644 index 0000000..e69de29 diff --git a/Sources/SwiftCLIKit/SwiftCLIKit.swift b/Sources/SwiftCLIKit/SwiftCLIKit.swift new file mode 100644 index 0000000..c2e71e9 --- /dev/null +++ b/Sources/SwiftCLIKit/SwiftCLIKit.swift @@ -0,0 +1,3 @@ +struct SwiftCLIKit { + var text = "Hello, World!" +} diff --git a/Sources/swiftcli/main.swift b/Sources/swiftcli/main.swift new file mode 100644 index 0000000..f2f3a28 --- /dev/null +++ b/Sources/swiftcli/main.swift @@ -0,0 +1,3 @@ +struct SwiftCLI { + var text = "Hello, World!" +} diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..c3e2227 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1 @@ +fatalError("Running tests like this is unsupported. Run the tests again by using `swift test --enable-test-discovery`") diff --git a/Tests/SwiftCLIKitTests/SwiftCLITests.swift b/Tests/SwiftCLIKitTests/SwiftCLITests.swift new file mode 100644 index 0000000..0d269fc --- /dev/null +++ b/Tests/SwiftCLIKitTests/SwiftCLITests.swift @@ -0,0 +1,11 @@ +@testable import SwiftCLIKit +import XCTest + +final class SwiftCLIKitTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(SwiftCLIKit().text, "Hello, World!") + } +}