feat: Working on node builder

This commit is contained in:
2024-12-01 15:25:42 -05:00
parent ff49b12198
commit 96a1fac07b
11 changed files with 357 additions and 21 deletions

View File

@@ -0,0 +1,41 @@
public struct ShellCommand: NodeRepresentable {
@usableFromInline
let symbol: any NodeRepresentable
@usableFromInline
let command: any NodeRepresentable
@inlinable
public init(
@NodeBuilder symbol: () -> any NodeRepresentable,
@NodeBuilder command: () -> any NodeRepresentable
) {
self.symbol = symbol()
self.command = command()
}
@inlinable
public init(
symbol: String = " $",
@NodeBuilder command: () -> any NodeRepresentable
) {
self.init { symbol } command: { command() }
}
@inlinable
public init(
symbol: String = " $",
command: String
) {
self.init { symbol } command: { command }
}
@inlinable
public func render() -> String {
Group(separator: " ") {
symbol
command
}.render()
}
}