feat: Moves core functionality into it's own library.

This commit is contained in:
2024-12-05 09:59:30 -05:00
parent 33356d8648
commit e7bbbec7c2
24 changed files with 464 additions and 387 deletions

View File

@@ -1,3 +1,5 @@
import Rainbow
public struct ShellCommand<Content: TextNode>: TextNode {
@usableFromInline
@@ -30,3 +32,32 @@ public extension ShellCommand where Content == String {
self.init(symbol: symbol) { content }
}
}
public struct ShellCommandConfiguration {
let symbol: any TextNode
let content: any TextNode
}
public extension ShellCommand {
func style<S: ShellCommandStyle>(_ style: S) -> some TextNode {
style.render(content: .init(symbol: symbol, content: content))
}
}
// MARK: - Style
public protocol ShellCommandStyle: NodeModifier where Self.Content == ShellCommandConfiguration {}
public extension ShellCommandStyle where Self == DefaultShellCommandStyle {
static var `default`: Self { DefaultShellCommandStyle() }
}
public struct DefaultShellCommandStyle: ShellCommandStyle {
public func render(content: ShellCommandConfiguration) -> some TextNode {
HStack {
content.symbol
content.content.textStyle(.italic)
}
}
}