colibri/Library/Sources/Public/Tasks/InitGitInFolderTask.swift
Javier Cicchelli 212ca52279 Template support for input parameters (#4)
This PR contains the work done to support input parameters for the `create` command of the executable target, and to render content dynamically for the newly-generated project.

Reviewed-on: #4
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
2025-02-17 22:11:05 +00:00

27 lines
822 B
Swift

import Foundation
public struct InitGitInFolderTask {
// MARK: Properties
private let terminalService: TerminalServicing
// MARK: Initialisers
public init(terminalService: TerminalServicing) {
self.terminalService = terminalService
}
// MARK: Functions
public func callAsFunction(at rootFolder: URL) async throws (TerminalServiceError) {
let executableURL = URL(at: "/usr/bin/git")
let pathFolder = rootFolder.pathString
try await terminalService.run(executableURL, arguments: ["init", pathFolder])
try await terminalService.run(executableURL, arguments: ["-C", pathFolder, "add", "."])
try await terminalService.run(executableURL, arguments: ["-C", pathFolder, "commit", "-m", "Initial commit"])
}
}