Scaffold v1.0.0

This commit is contained in:
T. R. Bernstein
2026-04-17 01:08:29 +02:00
commit b49d642dfd
22 changed files with 983 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import Foundation
struct CommandLineInvocation {
let sourceDirectory: URL
let outputFile: URL
}
extension CommandLineInvocation {
static func parse(_ arguments: [String]) throws -> CommandLineInvocation {
guard arguments.count == 3 else {
throw CommandLineInvocationError.wrongNumberOfArguments(received: arguments.count - 1)
}
return CommandLineInvocation(
sourceDirectory: URL(fileURLWithPath: arguments[1]),
outputFile: URL(fileURLWithPath: arguments[2])
)
}
}
enum CommandLineInvocationError: Error, CustomStringConvertible {
case wrongNumberOfArguments(received: Int)
var description: String {
switch self {
case .wrongNumberOfArguments(let received):
return "expected 2 arguments (source directory, output file); received \(received)"
}
}
}