sync: sync wip stuff
This commit is contained in:
@@ -1,32 +1,30 @@
|
||||
import type { Wush } from '../shell/Wush'
|
||||
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 wush: Wush
|
||||
private shell: Shell
|
||||
|
||||
constructor(wush: Wush) {
|
||||
constructor(shell: Shell) {
|
||||
super()
|
||||
this.wush = wush
|
||||
this.shell = shell
|
||||
}
|
||||
|
||||
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, args: string[]): Promise<number> {
|
||||
// stdout.emit('Not implemented yet.\n')
|
||||
// return 0
|
||||
|
||||
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, __: Item, args: string[]): Promise<number> {
|
||||
const javascript = args.slice(2).join(' ')
|
||||
|
||||
try {
|
||||
const exec: Function = eval(javascript)
|
||||
|
||||
const program = class extends Program {
|
||||
async Exec(stdin: SimpleStream<string>, stdout: SimpleStream<string>, args: string[]): Promise<number> {
|
||||
exec(stdin, stdout, args)
|
||||
async Exec(stdin: SimpleStream<string>, stdout: SimpleStream<string>, workdir: Item, args: string[]): Promise<number> {
|
||||
exec(stdin, stdout, workdir, args)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
this.wush.LoadProgram(new program(), args[1])
|
||||
this.shell.LoadProgram(new program(), args[1])
|
||||
} catch (e) {
|
||||
stdout.emit(`${String(e)}\n`)
|
||||
stdout.emit(`${String((e as Error).stack)}\n`)
|
||||
|
||||
Reference in New Issue
Block a user