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>
This commit was merged in pull request #4.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import Foundation
|
||||
|
||||
public protocol Bundleable {
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
var resourcePath: String? { get }
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ public protocol FileServicing {
|
||||
// MARK: Functions
|
||||
|
||||
func copyFile(from source: URL, to destination: URL) async throws (FileServiceError)
|
||||
func createFile(at location: URL, with data: Data) async throws (FileServiceError)
|
||||
func createFolder(at location: URL) async throws (FileServiceError)
|
||||
func deleteItem(at location: URL) async throws (FileServiceError)
|
||||
func isItemExists(at location: URL) async throws (FileServiceError) -> Bool
|
||||
@@ -18,6 +19,8 @@ public protocol FileServicing {
|
||||
// MARK: - Errors
|
||||
|
||||
public enum FileServiceError: Error, Equatable {
|
||||
case fileDataIsEmpty
|
||||
case fileNotCreated
|
||||
case folderNotCreated
|
||||
case itemAlreadyExists
|
||||
case itemEmptyData
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
public protocol TemplateServicing {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func render(_ object: Any, on template: String) async throws (TemplateServiceError) -> String
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Errors
|
||||
|
||||
public enum TemplateServiceError: Error {
|
||||
case contentNotRendered
|
||||
case resourcePathNotFound
|
||||
case serviceNotInitialized
|
||||
case templateNotFound
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import Foundation
|
||||
|
||||
public protocol TerminalServicing {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
@discardableResult
|
||||
func run(_ executableURL: URL, arguments: [String]) async throws (TerminalServiceError) -> String
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Errors
|
||||
|
||||
public enum TerminalServiceError: Error, Equatable {
|
||||
case captured(_ output: String)
|
||||
case output(_ output: String)
|
||||
case unexpected
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user