small tweaks to the file structure, and reorganization of the codebase.
preparations for session manager function implementations
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
import type { ShellError } from "./errors";
|
||||
import type { Result } from "./result";
|
||||
import type { ShellState } from "./shell_state";
|
||||
import type { ShellError } from "./util/errors";
|
||||
|
||||
type CommandFn = (state: ShellState, flags: string[], args: string[]) => CommandOutput<ShellError>;
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import type { CommandDescriptor, CommandOutput } from "@core/command";
|
||||
import type { FileSystem } from "@core/filesystem/filesystem";
|
||||
import { createErrorResult, createSuccessResult } from "@core/result";
|
||||
import { getCurrentSession } from "@core/session_manager";
|
||||
import { ShellState, withCwd } from "@core/shell_state";
|
||||
import {
|
||||
type InvalidArgumentsError,
|
||||
type PathResolutionError,
|
||||
type PermissionDeniedError,
|
||||
type ShellError,
|
||||
} from "@core/errors";
|
||||
import type { FileSystem } from "@core/filesystem/filesystem";
|
||||
import { resolveInode, resolvePath } from "@core/path_resolver";
|
||||
import { createErrorResult, createSuccessResult } from "@core/result";
|
||||
import { getCurrentSession } from "@core/session";
|
||||
import { ShellState, withCwd } from "@core/shell_state";
|
||||
} from "@core/util/errors";
|
||||
import { createImmutableBuffer } from "@core/util/immutable_buffer";
|
||||
import { resolveInode, resolvePath } from "@core/util/path_resolver";
|
||||
|
||||
export const COMMAND_NAME = "cd";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { CommandDescriptor, CommandOutput } from "@core/command";
|
||||
import type { ShellError } from "@core/errors";
|
||||
import type { ResultSuccess } from "@core/result";
|
||||
import type { ShellState } from "@core/shell_state";
|
||||
import type { ShellError } from "@core/util/errors";
|
||||
import { createImmutableBuffer } from "@core/util/immutable_buffer";
|
||||
|
||||
export const COMMAND_NAME = "echo";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { UserInfo } from "@core/user_info";
|
||||
import type { UserInfo } from "@core/session_manager";
|
||||
import { createImmutableBuffer, type ImmutableBuffer } from "@core/util/immutable_buffer";
|
||||
import { dnTraverseTree, upTraverseTree } from "@core/util/tree_traversal";
|
||||
import type {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { createShellError, type ShellError } from "./errors";
|
||||
import { createShellError, type ShellError } from "./util/errors";
|
||||
import { createImmutableBuffer, type ImmutableBuffer } from "./util/immutable_buffer";
|
||||
|
||||
export interface ResultError<E extends ShellError> {
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { type HistoryState } from "./history_state";
|
||||
import type { ShellState } from "./shell_state";
|
||||
import type { UserInfo } from "./user_info";
|
||||
|
||||
export interface UserInfo {
|
||||
readonly username: string;
|
||||
readonly uid: number;
|
||||
readonly gid: number;
|
||||
readonly group: readonly number[];
|
||||
readonly home: number;
|
||||
}
|
||||
|
||||
export interface SessionState {
|
||||
readonly user: UserInfo;
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { FileSystem } from "./filesystem/filesystem";
|
||||
import { addHistoryEntry } from "./history_state";
|
||||
import { createInitialSessionState, getCurrentSession, type SessionState } from "./session";
|
||||
import type { UserInfo } from "./user_info";
|
||||
import type { UserInfo } from "./session_manager";
|
||||
import { createInitialSessionState, getCurrentSession, type SessionState } from "./session_manager";
|
||||
|
||||
export interface ShellState {
|
||||
readonly filesystem: FileSystem;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
export interface UserInfo {
|
||||
readonly name: string;
|
||||
readonly uid: number;
|
||||
readonly gid: number;
|
||||
readonly group: readonly number[];
|
||||
readonly home: number;
|
||||
}
|
||||
@@ -43,8 +43,7 @@ const EXIT_CODE_MAP: Record<string, number> = {
|
||||
DataFormatError: 65,
|
||||
FileNotFound: 66,
|
||||
UserNotFound: 67,
|
||||
HostNotFound: 68,
|
||||
ServiceUnavailable: 69,
|
||||
LoginError: 68,
|
||||
InternalSoftwareError: 70,
|
||||
OperatingSystemError: 71,
|
||||
SystemFileError: 72,
|
||||
@@ -136,12 +135,9 @@ export interface UserNotFoundError extends ShellError {
|
||||
username: string;
|
||||
}
|
||||
|
||||
// ===================== 4. NETWORK / HOST / SERVICE ERRORS (Exit: 68, 69) =====================
|
||||
|
||||
/** Specified host does not exist or is unreachable (Exit 68 - EX_NOHOST) */
|
||||
export interface HostNotFoundError extends ShellError {
|
||||
errorType: "HostNotFound";
|
||||
hostname: string;
|
||||
export interface LoginError extends ShellError {
|
||||
errorType: "LoginError";
|
||||
user: number;
|
||||
}
|
||||
|
||||
/** Required service is unavailable (Exit 69 - EX_UNAVAILABLE) */
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { NodeNotFoundError, NotADirectoryError } from "./filesystem/errors";
|
||||
import type { FileSystem } from "./filesystem/filesystem";
|
||||
import { TreeNodeType, type DirectoryNode, type TreeNode } from "./filesystem/treenode";
|
||||
import type { NodeNotFoundError, NotADirectoryError } from "../filesystem/errors";
|
||||
import type { FileSystem } from "../filesystem/filesystem";
|
||||
import { TreeNodeType, type DirectoryNode, type TreeNode } from "../filesystem/treenode";
|
||||
|
||||
export function resolvePath(fs: FileSystem, cwd: number, path: string): number {
|
||||
const isAbsolute = path.startsWith("/");
|
||||
Reference in New Issue
Block a user