Add basic CLI commands

This commit is contained in:
Max Desiatov 2020-05-04 22:31:53 +01:00
parent 03b469fd51
commit 00507280de
No known key found for this signature in database
GPG Key ID: FE08EBF9CF58CBA2
8 changed files with 90 additions and 8 deletions

12
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,12 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build and run",
"type": "shell",
"command": "swift build && .build/debug/carton dev"
}
]
}

View File

@ -2,12 +2,21 @@
"object": {
"pins": [
{
"package": "SKQueue",
"repositoryURL": "https://github.com/daniel-pedersen/SKQueue.git",
"package": "async-http-client",
"repositoryURL": "https://github.com/swift-server/async-http-client.git",
"state": {
"branch": null,
"revision": "a52c15ea2a8f28fde607155cf75c1abe9ea000a7",
"version": "1.2.0"
"revision": "037b70291941fe43de668066eb6fb802c5e181d2",
"version": "1.1.1"
}
},
{
"package": "SKQueue",
"repositoryURL": "https://github.com/MaxDesiatov/SKQueue.git",
"state": {
"branch": "master",
"revision": "448a61e772c5beb60ab035b2af140e3165f71b23",
"version": null
}
},
{
@ -27,6 +36,33 @@
"revision": "e876fb37410e0036b98b5361bb18e6854739572b",
"version": "2.16.0"
}
},
{
"package": "swift-nio-extras",
"repositoryURL": "https://github.com/apple/swift-nio-extras.git",
"state": {
"branch": null,
"revision": "e0e76733600a2806b3dc4feae8cfebace858c1a2",
"version": "1.4.1"
}
},
{
"package": "swift-nio-http2",
"repositoryURL": "https://github.com/apple/swift-nio-http2.git",
"state": {
"branch": null,
"revision": "82eb3fa0974b838358ee46bc6c5381e5ae5de6b9",
"version": "1.11.0"
}
},
{
"package": "swift-nio-ssl",
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
"state": {
"branch": null,
"revision": "ae213938e151964aa691f0e902462fbe06baeeb6",
"version": "2.7.1"
}
}
]
},

View File

@ -7,15 +7,21 @@ let package = Package(
name: "carton",
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.0.5")),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.16.0"),
.package(url: "https://github.com/daniel-pedersen/SKQueue.git", from: "1.2.0"),
.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.11.0"),
.package(url: "https://github.com/MaxDesiatov/SKQueue.git", .branch("master")),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.1.1"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "carton",
dependencies: []
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "NIOHTTP2Server", package: "swift-nio-http2"),
.product(name: "AsyncHTTPClient", package: "async-http-client"),
.product(name: "SKQueue", package: "SKQueue"),
]
),
.testTarget(
name: "CartonTests",

View File

@ -0,0 +1,9 @@
import ArgumentParser
struct Carton: ParsableCommand {
static var configuration = CommandConfiguration(
abstract: "📦 Watcher, bundler, and test runner for your SwiftWasm apps.",
subcommands: [Dev.self, Test.self, Prod.self],
defaultSubcommand: Dev.self
)
}

7
Sources/carton/Dev.swift Normal file
View File

@ -0,0 +1,7 @@
import ArgumentParser
struct Dev: ParsableCommand {
static var configuration = CommandConfiguration(
abstract: "Watch the current directory, host the app, rebuild on change."
)
}

View File

@ -0,0 +1,7 @@
import ArgumentParser
struct Prod: ParsableCommand {
static var configuration = CommandConfiguration(
abstract: "Produce a production app bundle ready for deployment."
)
}

View File

@ -0,0 +1,5 @@
import ArgumentParser
struct Test: ParsableCommand {
static var configuration = CommandConfiguration(abstract: "Run the tests in a WASI environment.")
}

View File

@ -1 +1 @@
print("Hello, world!")
Carton.main()