Implemented the Create subcommand (#5)
This PR contains the work done to add the *Build* subcommand that build a *Hummingbird* project from the command line to the `Colibri` command. Reviewed-on: #5 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #5.
This commit is contained in:
@@ -7,7 +7,11 @@ struct Colibri: AsyncParsableCommand {
|
||||
|
||||
static let configuration = CommandConfiguration(
|
||||
abstract: "The utility to manage your Hummingbird apps",
|
||||
subcommands: [Create.self]
|
||||
subcommands: [
|
||||
Build.self,
|
||||
Create.self
|
||||
],
|
||||
defaultSubcommand: Create.self
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import ArgumentParser
|
||||
import ColibriLibrary
|
||||
|
||||
extension Colibri {
|
||||
struct Build: AsyncParsableCommand {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
static let configuration = CommandConfiguration(
|
||||
commandName: "build-project",
|
||||
abstract: "Build a Hummingbird app",
|
||||
helpNames: .shortAndLong,
|
||||
aliases: ["build"]
|
||||
)
|
||||
|
||||
@OptionGroup var options: Options
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
mutating func run() async throws {
|
||||
let terminalService = TerminalService()
|
||||
|
||||
let buildProject = BuildProjectTask(terminalService: terminalService)
|
||||
|
||||
try await buildProject(at: options.locationURL)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import ArgumentParser
|
||||
import ColibriLibrary
|
||||
|
||||
extension Colibri.Build {
|
||||
struct Options: ParsableArguments, Locationable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@Option(name: .shortAndLong)
|
||||
var location: String?
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import ArgumentParser
|
||||
import Foundation
|
||||
import ColibriLibrary
|
||||
|
||||
extension Colibri.Create {
|
||||
struct Options: ParsableArguments {
|
||||
struct Options: ParsableArguments, Locationable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@@ -11,12 +11,6 @@ extension Colibri.Create {
|
||||
|
||||
@Option(name: .shortAndLong)
|
||||
var location: String?
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
var locationURL: URL? {
|
||||
location.flatMap { URL(fileURLWithPath: $0) }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user