25 lines
688 B
TypeScript
25 lines
688 B
TypeScript
import type { Item } from '../fs/Item'
|
|
import type { Wush } from '../shell/wush/Wush'
|
|
import type { SimpleStream } from '../utils/SimpleStream'
|
|
import { Program } from './Program'
|
|
|
|
export class Lsprg extends Program {
|
|
private wush: Wush
|
|
|
|
constructor(wush: Wush) {
|
|
super()
|
|
this.wush = wush
|
|
}
|
|
|
|
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, __: Item, ___: string[]): Promise<number> {
|
|
const programs = this.wush.GetPrograms()
|
|
|
|
stdout.emit(`-> ${Object.keys(programs).length} loaded programs:\n`)
|
|
|
|
for (const program in this.wush.GetPrograms())
|
|
stdout.emit(` | - ${program}\n`)
|
|
|
|
return 0
|
|
}
|
|
}
|