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,20 @@
import Foundation
struct EmbedderTool {
func run(invocation: CommandLineInvocation) throws {
let discoveredFiles = try FileDiscovery().discoverEmbeddableFiles(in: invocation.sourceDirectory)
let namespaceTree = NamespaceTreeBuilder().buildTree(from: discoveredFiles)
let generatedSource = try SwiftCodeGenerator().generate(from: namespaceTree)
try writeAtomically(generatedSource, to: invocation.outputFile)
}
private func writeAtomically(_ contents: String, to file: URL) throws {
try createParentDirectoryIfNeeded(for: file)
try contents.write(to: file, atomically: true, encoding: .utf8)
}
private func createParentDirectoryIfNeeded(for file: URL) throws {
let parent = file.deletingLastPathComponent()
try FileManager.default.createDirectory(at: parent, withIntermediateDirectories: true)
}
}