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>
This commit was merged in pull request #3.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import ArgumentParser
|
||||
|
||||
@main
|
||||
struct Colibri: AsyncParsableCommand {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
static let configuration = CommandConfiguration(
|
||||
abstract: "The utility to manage your Hummingbird apps",
|
||||
subcommands: [Create.self]
|
||||
)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import ArgumentParser
|
||||
import Foundation
|
||||
|
||||
extension Colibri.Create {
|
||||
struct Options: ParsableArguments {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@Option(name: .shortAndLong)
|
||||
var name: String
|
||||
|
||||
@Option(name: .shortAndLong)
|
||||
var location: String?
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
var locationURL: URL? {
|
||||
location.flatMap { URL(fileURLWithPath: $0) }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user