- Fixed output formatting error in ls.ts
- Added an exported `Termos` object entry point - Defined a basic config for the entry point - Wrote a self contained initialization function for parsin the config into a returned `Shell` instance - Adjusted `dev.ts` to use the said entry point
This commit is contained in:
+1
-27
@@ -10,7 +10,6 @@ import { EventEmitter } from "./event_emitter";
|
||||
import { ProcessManager } from "./process_manager";
|
||||
|
||||
export class Shell {
|
||||
static #Instance: Shell | null;
|
||||
private _State: Readonly<ShellState>;
|
||||
private _ProcessManager: ProcessManager = new ProcessManager();
|
||||
private _EventEmitter: EventEmitter<ShellEventMap> = new EventEmitter();
|
||||
@@ -18,7 +17,7 @@ export class Shell {
|
||||
|
||||
public BoundPID: number | null = null;
|
||||
|
||||
private constructor(state: ShellState) {
|
||||
constructor(state: ShellState) {
|
||||
this._State = Object.freeze(state);
|
||||
|
||||
//Temporary solution for sigint keybind
|
||||
@@ -42,21 +41,6 @@ export class Shell {
|
||||
});
|
||||
}
|
||||
|
||||
static destroy(): void {
|
||||
Shell.#Instance = null;
|
||||
return;
|
||||
}
|
||||
|
||||
static init(initialState: ShellState): Shell {
|
||||
if (Shell.#Instance) {
|
||||
console.warn("Shell already initialized");
|
||||
return Shell.#Instance;
|
||||
}
|
||||
|
||||
Shell.#Instance = new Shell(initialState);
|
||||
return Shell.#Instance;
|
||||
}
|
||||
|
||||
public async execute(input: string): Promise<void> {
|
||||
const parsed = tokenize(input);
|
||||
|
||||
@@ -119,16 +103,6 @@ export class Shell {
|
||||
return this._State;
|
||||
}
|
||||
|
||||
public static Instance(initialState?: ShellState): Shell {
|
||||
if (!Shell.#Instance) {
|
||||
if (!initialState) {
|
||||
throw new Error("Shell needs to be initialized first");
|
||||
}
|
||||
Shell.#Instance = new Shell(initialState);
|
||||
}
|
||||
return Shell.#Instance;
|
||||
}
|
||||
|
||||
public on<K extends keyof ShellEventMap>(type: K, handler: (payload: ShellEventMap[K]) => void): () => void {
|
||||
return this._EventEmitter.on(type, handler);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user