import type { Item } from '../fs/Item' import type { Shell } from '../shell/Shell' import type { SimpleStream } from '../utils/SimpleStream' import { Program } from './Program' export class Loadprg extends Program { private shell: Shell constructor(shell: Shell) { super() this.shell = shell } async Exec(_: SimpleStream, stdout: SimpleStream, workdir: Item, args: string[]): Promise { const javascript = args.slice(2).join(' ') try { const program = eval(javascript) this.shell.LoadProgram(new program(), args[1]) } catch (e) { stdout.emit(`${String(e)}\n`) stdout.emit(`${String((e as Error).stack)}\n`) return 1 } return 0 } }