chore: make webfs usable

This commit is contained in:
binekrasik
2026-05-17 23:52:31 +02:00
parent f8335dcf5f
commit 4f4b72b915
14 changed files with 81 additions and 34 deletions

View File

@@ -7,17 +7,24 @@ export class Echo extends Program {
super()
}
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, ___: Item, args: string[]): Promise<number> {
let item: Item = await Item.open(args[1])
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, workdir: Item, args: string[]): Promise<number> {
if (args.length < 2) {
stdout.emit("echo: error: missing path argument\n")
return 1
}
const item = await Item.open(args[1].startsWith('/')
? args[1]
: `${workdir.GetPath()}${workdir.GetPath().endsWith('/') ? '' : '/'}${args[1]}`)
if (!(await item.Exists())) {
stdout.emit(`echo: error: item ${item.GetPath()} doesn't exist.\n`)
return 1
return 2
}
if (item.IsDirectory()) {
stdout.emit(`echo: error: can't write data to a directory; item ${item.GetPath()} is a directory.\n`)
return 2
return 3
}
await item.Write(args.slice(2).join(' '))