sync: wip changes
This commit is contained in:
@@ -3,17 +3,19 @@ import type { SimpleStream } from '../utils/SimpleStream'
|
|||||||
import { Program } from './Program'
|
import { Program } from './Program'
|
||||||
|
|
||||||
export class Eval extends Program {
|
export class Eval extends Program {
|
||||||
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, _workdir: Item, args: string[]): Promise<number> {
|
async Exec(stdin: SimpleStream<string>, stdout: SimpleStream<string>, _workdir: Item, args: string[]): Promise<number> {
|
||||||
const javascript = args.slice(1).join(' ')
|
let javascript: string = args.slice(1).join(' ')
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
private RunJs(javascript: string, stdout: SimpleStream<string>) {
|
||||||
try {
|
try {
|
||||||
// todo: pass workdir to the program
|
// todo: pass workdir to the program
|
||||||
eval(javascript)
|
eval(javascript)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
stdout.emit(`${String(e)}\n`)
|
stdout.emit(`${String(e)}\n`)
|
||||||
return 1
|
throw e
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ export class Loadprg extends Program {
|
|||||||
this.shell = shell
|
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(' ')
|
const javascript = args.slice(2).join(' ')
|
||||||
|
|
||||||
|
stdin.on(data => stdout.emit(`loadprg stdin: ${data}\x1B[0;30m\x1B[47m<- EOF\x1B[0m\n`))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const program = eval(javascript)
|
const program = eval(javascript)
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
import { Terminal } from '../../terminal/Terminal'
|
// Web-Uno Shell
|
||||||
import type { CursorPosition } from '../../terminal/CursorProperties'
|
// the best name I could come up with lol
|
||||||
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'
|
|
||||||
|
|
||||||
// import programs
|
|
||||||
import { Clear } from '../../program/Clear'
|
import { Clear } from '../../program/Clear'
|
||||||
import { Eval } from '../../program/Eval'
|
import { Eval } from '../../program/Eval'
|
||||||
import { Loadprg } from '../../program/Loadprg'
|
import { Loadprg } from '../../program/Loadprg'
|
||||||
import { Lsprg } from '../../program/Lsprg'
|
import { Lsprg } from '../../program/Lsprg'
|
||||||
import { Info } from '../../program/Info'
|
import { Info } from '../../program/Info'
|
||||||
import { Program } from '../../program/Program'
|
import { Program } from '../../program/Program'
|
||||||
import { Edit } from '../../program/Edit'
|
import { Terminal } from '../../terminal/Terminal'
|
||||||
import { Mv } from '../../program/Mv'
|
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 { Touch } from '../../program/Touch'
|
||||||
import { Sl } from '../../program/Sl'
|
import { Sl } from '../../program/Sl'
|
||||||
import { Rm } from '../../program/Rm'
|
import { Rm } from '../../program/Rm'
|
||||||
@@ -27,15 +25,11 @@ import { Mkdir } from '../../program/Mkdir'
|
|||||||
import { Cd } from '../../program/Cd'
|
import { Cd } from '../../program/Cd'
|
||||||
import { Printf } from '../../program/Printf'
|
import { Printf } from '../../program/Printf'
|
||||||
import { Pwd } from '../../program/Pwd'
|
import { Pwd } from '../../program/Pwd'
|
||||||
import { Ls } from '../../program/Ls'
|
import { Environment } from './Environment'
|
||||||
import { Cp } from '../../program/Cp'
|
import { InputManager } from './InputManager'
|
||||||
import { Tree } from '../../program/Tree'
|
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 {
|
export class Wush extends Shell {
|
||||||
public readonly Version = "0.3.2"
|
public readonly Version = "0.3.2"
|
||||||
public readonly Name = "wush"
|
public readonly Name = "wush"
|
||||||
@@ -102,8 +96,6 @@ export class Wush extends Shell {
|
|||||||
this.programs['printf'] = new Printf()
|
this.programs['printf'] = new Printf()
|
||||||
this.programs['edit'] = new Edit()
|
this.programs['edit'] = new Edit()
|
||||||
this.programs['mv'] = new Mv()
|
this.programs['mv'] = new Mv()
|
||||||
this.programs['cp'] = new Cp()
|
|
||||||
this.programs['tree'] = new Tree()
|
|
||||||
|
|
||||||
// reset exit code
|
// reset exit code
|
||||||
this.SetExitCode(0)
|
this.SetExitCode(0)
|
||||||
@@ -902,10 +894,6 @@ export class Wush extends Shell {
|
|||||||
this.terminal.NewPage()
|
this.terminal.NewPage()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
case 'm': {
|
|
||||||
this.terminal.ApplyCellStyleCodes(values)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user