diff --git a/src/program/Eval.ts b/src/program/Eval.ts index 45882f1..81470c8 100644 --- a/src/program/Eval.ts +++ b/src/program/Eval.ts @@ -3,17 +3,19 @@ import type { SimpleStream } from '../utils/SimpleStream' import { Program } from './Program' export class Eval extends Program { - async Exec(_: SimpleStream, stdout: SimpleStream, _workdir: Item, args: string[]): Promise { - const javascript = args.slice(1).join(' ') + async Exec(stdin: SimpleStream, stdout: SimpleStream, _workdir: Item, args: string[]): Promise { + let javascript: string = args.slice(1).join(' ') + return 0 + } + + private RunJs(javascript: string, stdout: SimpleStream) { try { // todo: pass workdir to the program eval(javascript) } catch (e) { stdout.emit(`${String(e)}\n`) - return 1 + throw e } - - return 0 } } diff --git a/src/program/Loadprg.ts b/src/program/Loadprg.ts index feff457..8900fe1 100644 --- a/src/program/Loadprg.ts +++ b/src/program/Loadprg.ts @@ -11,9 +11,11 @@ export class Loadprg extends Program { this.shell = shell } - async Exec(_: SimpleStream, stdout: SimpleStream, __: Item, args: string[]): Promise { + async Exec(stdin: SimpleStream, stdout: SimpleStream, __: Item, args: string[]): Promise { const javascript = args.slice(2).join(' ') + stdin.on(data => stdout.emit(`loadprg stdin: ${data}\x1B[0;30m\x1B[47m<- EOF\x1B[0m\n`)) + try { const program = eval(javascript) diff --git a/src/shell/wush/Wush.ts b/src/shell/wush/Wush.ts index 5646676..fab3e62 100644 --- a/src/shell/wush/Wush.ts +++ b/src/shell/wush/Wush.ts @@ -1,21 +1,19 @@ -import { Terminal } from '../../terminal/Terminal' -import type { CursorPosition } from '../../terminal/CursorProperties' -import { EventBroadcaster } from '../../utils/EventBroadcaster' -import { SimpleStream } from '../../utils/SimpleStream' -import { Shell } from '../Shell' -import { Item } from '../../fs/Item' -import { Environment } from './Environment' -import { InputManager } from './InputManager' +// Web-Uno Shell +// the best name I could come up with lol -// import programs import { Clear } from '../../program/Clear' import { Eval } from '../../program/Eval' import { Loadprg } from '../../program/Loadprg' import { Lsprg } from '../../program/Lsprg' import { Info } from '../../program/Info' import { Program } from '../../program/Program' -import { Edit } from '../../program/Edit' -import { Mv } from '../../program/Mv' +import { Terminal } from '../../terminal/Terminal' +import type { CursorPosition } from '../../terminal/CursorProperties' +import { EventBroadcaster } from '../../utils/EventBroadcaster' +import { SimpleStream } from '../../utils/SimpleStream' +import { Shell } from '../Shell' +import { Ls } from '../../program/Ls' +import { Item } from '../../fs/Item' import { Touch } from '../../program/Touch' import { Sl } from '../../program/Sl' import { Rm } from '../../program/Rm' @@ -27,15 +25,11 @@ import { Mkdir } from '../../program/Mkdir' import { Cd } from '../../program/Cd' import { Printf } from '../../program/Printf' import { Pwd } from '../../program/Pwd' -import { Ls } from '../../program/Ls' -import { Cp } from '../../program/Cp' -import { Tree } from '../../program/Tree' +import { Environment } from './Environment' +import { InputManager } from './InputManager' +import { Edit } from '../../program/Edit' +import { Mv } from '../../program/Mv' -/** - * Web-Uno Shell - * - the best name I could come up with lol - * @description serves as the default shell idk - */ export class Wush extends Shell { public readonly Version = "0.3.2" public readonly Name = "wush" @@ -102,8 +96,6 @@ export class Wush extends Shell { this.programs['printf'] = new Printf() this.programs['edit'] = new Edit() this.programs['mv'] = new Mv() - this.programs['cp'] = new Cp() - this.programs['tree'] = new Tree() // reset exit code this.SetExitCode(0) @@ -902,10 +894,6 @@ export class Wush extends Shell { this.terminal.NewPage() return true } - case 'm': { - this.terminal.ApplyCellStyleCodes(values) - return true - } default: return false }