cd fixed and cleaned up. Shell started, needs data fetching code to initialize properly, added the approperiate db_manager file to implement that.

This commit is contained in:
2026-08-08 08:11:19 +02:00
parent 394e0b9e7c
commit 0149937526
3 changed files with 74 additions and 24 deletions
+49
View File
@@ -0,0 +1,49 @@
import type { Result } from "@core/result";
import { type ShellState } from "@core/shell_state";
import type { ShellError } from "@core/util/errors";
export class Shell {
static #instance: Shell;
static #promise: Promise<Shell> | null = null;
private readonly state: Readonly<ShellState>;
private constructor(state: ShellState) {
this.state = Object.freeze(state);
}
static async init(): Promise<Shell> {
if (Shell.#instance) {
console.warn("Shell already initialized");
return this.#instance;
}
if (Shell.#promise) return Shell.#promise;
const state; //Create initial shell state,
Shell.#promise = (async () => {
try {
Shell.#instance = new Shell();
return Shell.#instance;
} finally {
Shell.#promise = null;
}
})();
return Shell.#promise;
}
public async Execute(input: string): Promise<Result<ShellError>> {}
public get State(): Readonly<ShellState> {
return this.state;
}
public static get Instance(): Shell | undefined {
if (!Shell.#instance) {
console.error("Shell has not been initialised yet. Call `await Singleton.init()` first.");
return;
}
return Shell.#instance;
}
}