sync: wip changes

This commit is contained in:
binekrasik
2026-05-22 14:48:00 +02:00
parent 62038c2814
commit 4777552106
3 changed files with 23 additions and 31 deletions

View File

@@ -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
}
return 0
throw e
}
}
}

View File

@@ -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)

View File

@@ -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
}