feat: add some utilities

This commit is contained in:
2026-03-26 22:33:04 +01:00
parent 21a1a34309
commit 983cf59476
10 changed files with 119 additions and 27 deletions

29
src/program/Loadprg.ts Normal file
View File

@@ -0,0 +1,29 @@
import type { Wush } from '../shell/Wush'
import type { SimpleStream } from '../utils/SimpleStream'
import { Program } from './Program'
export class Loadprg extends Program {
// private wush: Wush
constructor(_: Wush) {
super()
// this.wush = wush
}
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, args: string[]): Promise<number> {
stdout.emit('Not implemented yet.\n')
return 0
const javascript = args.slice(1).join(' ')
try {
eval(javascript)
} catch (e) {
stdout.emit(`${String(e)}\n`)
stdout.emit(`${String((e as Error).stack)}\n`)
return 1
}
return 0
}
}