SwiftFileBuilder for programmatic Swift code generation

I'm open sourcing my library SwiftFileBuilder.

Build your source file like this:

import SwiftFileBuilder

var file = SwiftFileBuilder()

file.appendImport(module: "Foundation")

file.appendType(accessLevel: .public, kind: .struct, name: "Person") { type in
    type.appendStoredProperty(accessLevel: .public, name: "name", type: "String")
    type.appendStoredProperty(accessLevel: .public, name: "age", type: "Int")

    type.appendInitializer(accessLevel: .public, arguments: [
        SwiftFunctionArgument(name: "name", type: "String"),
        SwiftFunctionArgument(name: "age", type: "Int"),
    ]) { fn in
        fn.append(line: "self.name = name")
        fn.append(line: "self.age = age")
    }
}

let output = file.finalize()

And you'll have an output file perfectly indented!

import Foundation

public struct Person {
    public var name: String
    public var age: Int

    public init(name: String, age: Int) {
        self.name = name
        self.age = age
    }
}

I developed this code generation tool for my Swift interpreter project. This also marks the last external dependency SwiftLite (the interpreter) needed to be open sourced. Now I can begin open sourcing the interpreter itself...which will take awhile.