From 0225ece2f94bd558e76499d648b3f9c1a4237e75 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Wed, 19 Feb 2025 02:00:18 +0100 Subject: [PATCH] Implemented the CleanCommand command in the executable target. --- .../Sources/Commands/CleanCommand.swift | 31 +++++++++++++++++++ Executable/Sources/Options/CleanOptions.swift | 19 ++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Executable/Sources/Commands/CleanCommand.swift create mode 100644 Executable/Sources/Options/CleanOptions.swift diff --git a/Executable/Sources/Commands/CleanCommand.swift b/Executable/Sources/Commands/CleanCommand.swift new file mode 100644 index 0000000..2b9b334 --- /dev/null +++ b/Executable/Sources/Commands/CleanCommand.swift @@ -0,0 +1,31 @@ +import ArgumentParser +import ColibriLibrary + +extension Colibri { + struct Clean: AsyncParsableCommand { + + // MARK: Properties + + static let configuration = CommandConfiguration( + commandName: "clean-project", + abstract: "Clean a Hummingbird app", + helpNames: .shortAndLong, + aliases: ["clean"] + ) + + @OptionGroup var options: Options + + // MARK: Functions + + mutating func run() async throws { + let terminalService = TerminalService() + + let cleanProject = CleanProjectTask(terminalService: terminalService) + + try await cleanProject(at: options.locationURL, + shouldReset: options.reset, + purgeCache: options.purgeCache) + } + + } +} diff --git a/Executable/Sources/Options/CleanOptions.swift b/Executable/Sources/Options/CleanOptions.swift new file mode 100644 index 0000000..8390fcc --- /dev/null +++ b/Executable/Sources/Options/CleanOptions.swift @@ -0,0 +1,19 @@ +import ArgumentParser +import ColibriLibrary + +extension Colibri.Clean { + struct Options: ParsableArguments, Locationable { + + // MARK: Properties + + @Flag(name: .shortAndLong) + var reset: Bool = false + + @Flag(name: .shortAndLong) + var purgeCache: Bool = false + + @Option(name: .shortAndLong) + var location: String? + + } +}