2025-01-12 01:42:43 +01:00
|
|
|
import ArgumentParser
|
|
|
|
import ColibriLibrary
|
|
|
|
|
|
|
|
extension Colibri {
|
|
|
|
struct Create: AsyncParsableCommand {
|
|
|
|
|
|
|
|
// MARK: Properties
|
|
|
|
|
|
|
|
static let configuration = CommandConfiguration(
|
2025-01-12 02:41:17 +01:00
|
|
|
commandName: "create-project",
|
|
|
|
abstract: "Create a new, tailored Hummingbird app",
|
2025-01-12 01:42:43 +01:00
|
|
|
helpNames: .shortAndLong,
|
|
|
|
aliases: ["create"]
|
|
|
|
)
|
2025-01-13 00:36:56 +01:00
|
|
|
|
2025-01-12 01:42:43 +01:00
|
|
|
@OptionGroup var options: Options
|
2025-01-12 02:41:17 +01:00
|
|
|
|
2025-01-12 01:42:43 +01:00
|
|
|
// MARK: Functions
|
|
|
|
|
|
|
|
mutating func run() async throws {
|
2025-01-12 02:41:17 +01:00
|
|
|
let fileService = FileService()
|
2025-01-16 00:31:53 +01:00
|
|
|
|
2025-01-16 01:46:42 +01:00
|
|
|
let copyFiles = CopyFilesTask(fileService: fileService)
|
2025-01-13 00:36:56 +01:00
|
|
|
let createFolders = CreateFoldersTask(fileService: fileService)
|
2025-01-16 00:31:53 +01:00
|
|
|
let createRootFolder = CreateRootFolderTask(fileService: fileService)
|
2025-01-12 02:41:17 +01:00
|
|
|
|
|
|
|
let rootFolder = try await createRootFolder(
|
|
|
|
name: options.name,
|
|
|
|
at: options.locationURL
|
|
|
|
)
|
2025-01-13 00:36:56 +01:00
|
|
|
|
|
|
|
try await createFolders(at: rootFolder)
|
2025-01-16 01:46:42 +01:00
|
|
|
try await copyFiles(to: rootFolder)
|
2025-01-12 01:42:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|