ProzillaOS/packages/apps/terminal/core/commands/whatis.ts
2024-06-16 21:46:44 +02:00

22 lines
No EOL
757 B
TypeScript

import { ANSI } from "../../../../config/apps/terminal.config";
import { formatError } from "../_utils/terminal.utils";
import { Command } from "../command";
import { CommandsManager } from "../commands";
export const whatis = new Command()
.setRequireArgs(true)
.setManual({
purpose: "Show information about a command"
})
.setExecute(function(this: Command, args) {
const commandName = (args as string[])[0].toLowerCase();
const command = CommandsManager.find(commandName);
if (!command)
return formatError(this.name, `${commandName}: Command not found`);
if (!command.manual?.purpose)
return formatError(this.name, `${commandName}: No information found`);
return `${commandName} - ${ANSI.fg.green}${command.manual.purpose}`;
});