Disable default subcommand, enable version flag
This commit is contained in:
parent
bd9cb4c2cb
commit
b3b1144f59
|
@ -3,6 +3,16 @@
|
|||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build and run",
|
||||
"type": "shell",
|
||||
"command": "swift build && cd TestApp && ../.build/debug/carton"
|
||||
},
|
||||
{
|
||||
"label": "build and version",
|
||||
"type": "shell",
|
||||
"command": "swift build && cd TestApp && ../.build/debug/carton --version"
|
||||
},
|
||||
{
|
||||
"label": "build and run dev",
|
||||
"type": "shell",
|
||||
|
|
|
@ -29,13 +29,13 @@ instead of Foundation's `URLSession` for dependency downloads.
|
|||
# 0.1.0 (16 June 2020)
|
||||
|
||||
Since SwiftPM doesn't always build an executable target even if one is present without
|
||||
an explicit `--product` flag, the `dev` command now requires the presence of an executable
|
||||
target in your `Package.swift`. Use the new `--product` flag instead of `--target` to
|
||||
an explicit `--product` option, the `dev` command now requires the presence of an executable
|
||||
target in your `Package.swift`. Use the new `--product` option instead of `--target` to
|
||||
disambiguate between multiple executable targets.
|
||||
|
||||
# 0.0.5 (16 June 2020)
|
||||
|
||||
Pass `--target` flag to `swift build` when running the `dev` command.
|
||||
Pass `--target` option to `swift build` when running the `dev` command.
|
||||
|
||||
# 0.0.4 (16 June 2020)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import ArgumentParser
|
|||
struct Carton: ParsableCommand {
|
||||
static var configuration = CommandConfiguration(
|
||||
abstract: "📦 Watcher, bundler, and test runner for your SwiftWasm apps.",
|
||||
subcommands: [Dev.self, Test.self, Bundle.self],
|
||||
defaultSubcommand: Dev.self
|
||||
version: "0.1.5",
|
||||
subcommands: [Dev.self, Test.self, Bundle.self]
|
||||
)
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ struct Dev: ParsableCommand {
|
|||
try dependency.check(on: localFileSystem, terminal)
|
||||
let swiftPath = try localFileSystem.inferSwiftPath(terminal)
|
||||
guard let product = try Package(with: swiftPath, terminal)
|
||||
.inferDevProduct(with: swiftPath, flag: product, terminal)
|
||||
.inferDevProduct(with: swiftPath, option: product, terminal)
|
||||
else { return }
|
||||
|
||||
let binPath = try localFileSystem.inferBinPath(swiftPath: swiftPath)
|
||||
|
|
|
@ -33,14 +33,14 @@ struct Package: Codable {
|
|||
|
||||
func inferDevProduct(
|
||||
with swiftPath: String,
|
||||
flag: String?,
|
||||
option: String?,
|
||||
_ terminal: TerminalController
|
||||
) -> String? {
|
||||
var candidateProducts = products
|
||||
.filter { $0.type.library == nil }
|
||||
.map(\.name)
|
||||
|
||||
if let product = flag {
|
||||
if let product = option {
|
||||
candidateProducts = candidateProducts.filter { $0 == product }
|
||||
|
||||
guard candidateProducts.count == 1 else {
|
||||
|
@ -59,7 +59,7 @@ struct Package: Codable {
|
|||
terminal.write("Failed to disambiguate the development product\n", inColor: .red)
|
||||
|
||||
if candidateProducts.count > 1 {
|
||||
terminal.write("Pass one of \(candidateProducts) to the --product flag\n", inColor: .red)
|
||||
terminal.write("Pass one of \(candidateProducts) to the --product option\n", inColor: .red)
|
||||
} else {
|
||||
terminal.write(
|
||||
"Make sure there's at least one executable product in your Package.swift\n",
|
||||
|
|
Loading…
Reference in New Issue