Bugfixes and improvements
- ls fixed - fixed a bug where ~ wouldnt resolve properly - temporarily increased the process chunking treshold, because chunking breaks formatting - added clear - added pwd
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import type { CommandDescriptor, CommandOutput } from "@core/command";
|
||||
import type { CommandIO } from "@core/command_io";
|
||||
import { createErrorResult, createSuccessResult, type ResultSuccess } from "@core/result";
|
||||
import { getCurrentSession } from "@core/session_manager";
|
||||
import type { ShellState } from "@core/shell_state";
|
||||
import type { InvalidArgumentsError, ShellError } from "@core/util/errors";
|
||||
import { resolveInode } from "@core/util/path_resolver";
|
||||
|
||||
export const COMMAND_NAME = "pwd";
|
||||
|
||||
//Need to implement escape sequences
|
||||
async function main(io: CommandIO, state: ShellState, args: string[]): Promise<CommandOutput<ShellError>> {
|
||||
if (args.length > 0) {
|
||||
return {
|
||||
state,
|
||||
result: createErrorResult(
|
||||
"InvalidArguments",
|
||||
`Expected aruments 0, got ${args.length}.`,
|
||||
{ expected: "pwd", actual: `pwd ${args.toString().replace(/[,]/g, " ")}` },
|
||||
COMMAND_NAME,
|
||||
),
|
||||
} satisfies CommandOutput<InvalidArgumentsError>;
|
||||
}
|
||||
|
||||
const session = getCurrentSession(state);
|
||||
const path = resolveInode(state, session.cwd);
|
||||
|
||||
io.writeStdout(new TextEncoder().encode(path));
|
||||
|
||||
const result: ResultSuccess = createSuccessResult(COMMAND_NAME);
|
||||
|
||||
return {
|
||||
state: state,
|
||||
result,
|
||||
};
|
||||
}
|
||||
|
||||
export const descriptor: CommandDescriptor = {
|
||||
fn: main,
|
||||
name: COMMAND_NAME,
|
||||
};
|
||||
Reference in New Issue
Block a user