sync: wip changes
This commit is contained in:
@@ -3,17 +3,19 @@ import type { SimpleStream } from '../utils/SimpleStream'
|
||||
import { Program } from './Program'
|
||||
|
||||
export class Eval extends Program {
|
||||
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, _workdir: Item, args: string[]): Promise<number> {
|
||||
const javascript = args.slice(1).join(' ')
|
||||
async Exec(stdin: SimpleStream<string>, stdout: SimpleStream<string>, _workdir: Item, args: string[]): Promise<number> {
|
||||
let javascript: string = args.slice(1).join(' ')
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
private RunJs(javascript: string, stdout: SimpleStream<string>) {
|
||||
try {
|
||||
// todo: pass workdir to the program
|
||||
eval(javascript)
|
||||
} catch (e) {
|
||||
stdout.emit(`${String(e)}\n`)
|
||||
return 1
|
||||
throw e
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ export class Loadprg extends Program {
|
||||
this.shell = shell
|
||||
}
|
||||
|
||||
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, __: Item, args: string[]): Promise<number> {
|
||||
async Exec(stdin: SimpleStream<string>, stdout: SimpleStream<string>, __: Item, args: string[]): Promise<number> {
|
||||
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)
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user