Skip to content

Commit

Permalink
Started FileSystem example
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneenders committed Jul 4, 2024
1 parent c384cf1 commit 8328497
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ let package = Package(
],
targets: [
.executableTarget(
name: "TestChromaClient",
name: "FileSystem",
dependencies: [
"ChromaShell"
],
swiftSettings: swiftSettings),
.executableTarget(
name: "AsyncUpdate",
dependencies: [
"ChromaShell"
],
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ Checkout the docs for more details about the project.
## More Examples

[Shell Example](Sources/ShellExample/ShellExample.swift)
A simple example of running a shell command in the background
A simple example of running a shell command in the background.

[AsyncUpdate](Sources/AsyncUpdate/AsyncUpdate.swift)
Shows the ui updating from an external async source.

[FileSystem](Sources/FileSystem/FileSystem.swift)
An example browsing the file system.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Observation
import ScribeCore

@main
struct TestChromaClient: ChromaShell {
struct AsyncUpdate: ChromaShell {
var main: some Block {
TestBlock()
}
Expand Down
1 change: 0 additions & 1 deletion Sources/ChromaShell/ChromaShell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ extension ChromaShell {
}
}


func draw(_ visible: VisibleNode, _ x: Int, _ y: Int) {
let ascii = visible.drawVisible(x, y).0
ChromaFrame(ascii, .default, .default).render()
Expand Down
29 changes: 29 additions & 0 deletions Sources/FileSystem/FileSystem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import ChromaShell
import Foundation
import Observation
import ScribeCore

@Observable
final class FileSystemManager {
var cwd: String
init() {
self.cwd = FileManager.default.currentDirectoryPath
}
}

struct FileSystemBlock: Block {
init() {}
let fileSystem = FileSystemManager()
var component: some Block {
"\(fileSystem.cwd)"
}
}

@main
struct FileSystem: ChromaShell {
var main: some Block {
// Creates a new process and writes the output to test.txt in the
// current working directory
FileSystemBlock()
}
}

0 comments on commit 8328497

Please sign in to comment.