From cbd3789ca7e45e13be4faf9107473b5f3b45d50b Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 12 Jan 2025 02:41:17 +0100 Subject: [PATCH] Implemented the creation of a root folder within the Create command in the executable target. --- Sources/Executable/Colibri.swift | 2 +- Sources/Executable/Commands/Create.swift | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Sources/Executable/Colibri.swift b/Sources/Executable/Colibri.swift index a27ae37..194d287 100644 --- a/Sources/Executable/Colibri.swift +++ b/Sources/Executable/Colibri.swift @@ -6,7 +6,7 @@ struct Colibri: AsyncParsableCommand { // MARK: Properties static let configuration = CommandConfiguration( - abstract: "The utility to manage your Hummingbird projects", + abstract: "The utility to manage your Hummingbird apps", subcommands: [Create.self] ) diff --git a/Sources/Executable/Commands/Create.swift b/Sources/Executable/Commands/Create.swift index d65c947..a8d4373 100644 --- a/Sources/Executable/Commands/Create.swift +++ b/Sources/Executable/Commands/Create.swift @@ -1,5 +1,6 @@ import ArgumentParser import ColibriLibrary +import Foundation extension Colibri { struct Create: AsyncParsableCommand { @@ -7,18 +8,26 @@ extension Colibri { // MARK: Properties static let configuration = CommandConfiguration( - commandName: "create project", - abstract: "Create a new, tailored Colibri project.", + commandName: "create-project", + abstract: "Create a new, tailored Hummingbird app", helpNames: .shortAndLong, aliases: ["create"] ) @OptionGroup var options: Options - + // MARK: Functions mutating func run() async throws { - + let fileService = FileService() + let createRootFolder = CreateRootFolderTask(fileService: fileService) + + let rootFolder = try await createRootFolder( + name: options.name, + at: options.locationURL + ) + + print(rootFolder) } } @@ -36,6 +45,12 @@ extension Colibri.Create { @Option(name: .shortAndLong) var location: String? + + // MARK: Computed + + var locationURL: URL? { + location.flatMap { URL(fileURLWithPath: $0) } + } } }