From b3b1144f59b4b806fa4b072a37477521083e6698 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 22 Jun 2020 13:11:20 +0100 Subject: [PATCH] Disable default subcommand, enable version flag --- .vscode/tasks.json | 10 ++++++++++ CHANGELOG.md | 6 +++--- Sources/carton/Carton.swift | 4 ++-- Sources/carton/Commands/Dev.swift | 2 +- Sources/carton/Model/Package.swift | 6 +++--- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ecd2709..789556e 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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", diff --git a/CHANGELOG.md b/CHANGELOG.md index f4accd6..3e043d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Sources/carton/Carton.swift b/Sources/carton/Carton.swift index 482dea5..2e8d929 100644 --- a/Sources/carton/Carton.swift +++ b/Sources/carton/Carton.swift @@ -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] ) } diff --git a/Sources/carton/Commands/Dev.swift b/Sources/carton/Commands/Dev.swift index 6308b5f..2858300 100644 --- a/Sources/carton/Commands/Dev.swift +++ b/Sources/carton/Commands/Dev.swift @@ -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) diff --git a/Sources/carton/Model/Package.swift b/Sources/carton/Model/Package.swift index 975455c..b07243e 100644 --- a/Sources/carton/Model/Package.swift +++ b/Sources/carton/Model/Package.swift @@ -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",