Implemented the OpenCommand subcommand in the executable target.

This commit is contained in:
Javier Cicchelli 2025-02-20 00:23:12 +01:00
parent 0b2bcd6d1e
commit 77363a7c0e
3 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import ArgumentParser
import ColibriLibrary
extension Colibri {
struct Open: AsyncParsableCommand {
// MARK: Properties
static let configuration = CommandConfiguration(
commandName: "open-project",
abstract: "Open a Hummingbird app",
helpNames: .shortAndLong,
aliases: ["open"]
)
@OptionGroup var options: Options
// MARK: Functions
mutating func run() async throws {
let terminalService = TerminalService()
let openProject = OpenProjectTask(terminalService: terminalService)
try await openProject(with: options.ide, at: options.locationURL)
}
}
}

View File

@ -0,0 +1,6 @@
import ArgumentParser
import ColibriLibrary
// MARK: - ExpressibleByArgument
extension IDE: ExpressibleByArgument {}

View File

@ -0,0 +1,16 @@
import ArgumentParser
import ColibriLibrary
extension Colibri.Open {
struct Options: ParsableArguments, Locationable {
// MARK: Properties
@Option(name: .shortAndLong)
var ide: IDE = .xcode
@Option(name: .shortAndLong)
var location: String?
}
}