colibri/Executable/Sources/Commands/CreateCommand.swift
Javier Cicchelli 9be8fa4a31 Basic project creation (#3)
This PR contains the work done to create a new *Hummingbird* project with very basic configuration from the _colibri_ executable, just like the project you could create with the [Hummingbird template](https://github.com/hummingbird-project/template) project in Github.

Reviewed-on: #3
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
2025-01-28 00:07:24 +00:00

40 lines
1.2 KiB
Swift

import ArgumentParser
import ColibriLibrary
extension Colibri {
struct Create: AsyncParsableCommand {
// MARK: Properties
static let configuration = CommandConfiguration(
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 copyFiles = CopyFilesTask(fileService: fileService)
let createFolders = CreateFoldersTask(fileService: fileService)
let createRootFolder = CreateRootFolderTask(fileService: fileService)
let initGitInFolder = InitGitInFolderTask()
let rootFolder = try await createRootFolder(
name: options.name,
at: options.locationURL
)
try await createFolders(at: rootFolder)
try await copyFiles(to: rootFolder)
try await initGitInFolder(at: rootFolder)
}
}
}