From 77363a7c0e89403f93565691da9f1b94a9243ab8 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Thu, 20 Feb 2025 00:23:12 +0100 Subject: [PATCH] Implemented the OpenCommand subcommand in the executable target. --- Executable/Sources/Commands/OpenCommand.swift | 29 +++++++++++++++++++ .../Sources/Extensions/IDE+Conformances.swift | 6 ++++ Executable/Sources/Options/OpenOptions.swift | 16 ++++++++++ 3 files changed, 51 insertions(+) create mode 100644 Executable/Sources/Commands/OpenCommand.swift create mode 100644 Executable/Sources/Extensions/IDE+Conformances.swift create mode 100644 Executable/Sources/Options/OpenOptions.swift diff --git a/Executable/Sources/Commands/OpenCommand.swift b/Executable/Sources/Commands/OpenCommand.swift new file mode 100644 index 0000000..688659c --- /dev/null +++ b/Executable/Sources/Commands/OpenCommand.swift @@ -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) + } + + } +} diff --git a/Executable/Sources/Extensions/IDE+Conformances.swift b/Executable/Sources/Extensions/IDE+Conformances.swift new file mode 100644 index 0000000..413ea49 --- /dev/null +++ b/Executable/Sources/Extensions/IDE+Conformances.swift @@ -0,0 +1,6 @@ +import ArgumentParser +import ColibriLibrary + +// MARK: - ExpressibleByArgument + +extension IDE: ExpressibleByArgument {} diff --git a/Executable/Sources/Options/OpenOptions.swift b/Executable/Sources/Options/OpenOptions.swift new file mode 100644 index 0000000..4f94ec7 --- /dev/null +++ b/Executable/Sources/Options/OpenOptions.swift @@ -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? + + } +}