Files
gornodox.dev/src/lib/stores/bash/commandRegistry.ts
T

151 lines
3.0 KiB
TypeScript

import { isBuildCommand } from "typescript";
import type { KeyBind } from "../terminal/keybindRegistry";
import type { Bash, Result } from "./bash";
import { cd } from "./commands/cd";
import { clear } from "./commands/clear";
import { ls } from "./commands/ls";
import { testProcess } from "./commands/testAsync";
export type ICommand = {
method: (this: Bash, args: CommandArgs) => Result;
keybinds?: Map<KeyBind, () => any>;
flags: string[];
help: string;
root: boolean;
};
export type CommandArgs = {
flags: string[];
args: string[];
};
export type CommandResultData = {
cmd: string; //the string that contains the shorthand for the command that was executed - used in a switch statement in parseResult
data: any; //the data that the commmand may have returned like TreeNodes[] from ls
args?: CommandArgs;
};
export const COMMANDS = {
cd,
ls,
clear,
testProcess
} as const satisfies Record<string, ICommand>;
/* //export const commands {
return: {
method: this.cmd_return,
flags: [],
help: "Help about this command",
},
ls: {
method: this.cmd_ls,
flags: [],
help: "./help/ls.md",
},
echo: {
method: this.cmd_echo,
flags: [],
help: "",
},
touch: {
method: this.cmd_touch,
flags: [],
help: "",
},
mkdir: {
method: this.cmd_mkdir,
flags: [],
help: "",
},
pwd: {
method: this.cmd_pwd,
flags: [],
help: "",
},
cd: {
method: this.cmd_cd,
flags: [],
help: "",
},
exit: {
method: this.cmd_exit,
flags: [],
help: "",
},
cp: {
method: this.cmd_cp,
flags: [],
help: "",
},
mv: {
method: this.cmd_mv,
flags: [],
help: "",
},
rmdir: {
method: this.cmd_rmdir,
flags: [],
help: "",
},
cat: {
method: this.cmd_cat,
flags: [],
help: "",
},
dir: {
method: this.cmd_dir,
flags: [],
help: "",
},
less: {
method: this.cmd_less,
flags: [],
help: "",
},
chown: {
method: this.cmd_chown,
flags: [],
help: "",
},
chmod: {
method: this.cmd_chmod,
flags: [],
help: "",
},
reboot: {
method: this.cmd_reboot,
flags: [],
help: "",
},
help: {
method: this.cmd_help,
flags: [],
help: "",
},
whoami: {
method: this.cmd_whoami,
flags: [],
help: "",
},
rm: {
method: this.cmd_rm,
flags: [],
help: "",
},
sudo: {
method: this.cmd_sudo,
flags: [],
help: "",
},
su: {
method: this.cmd_su,
flags: [],
help: "",
},
clear: {
method: this.cmd_clear,
flags: [],
help: "",
}
} */