Command: {
    args?: string[];
    callback?: Awaitable<void>;
    description?: string;
    handler: CommandHandler;
    name: string;
    onError?: CommandErrorHandler;
    usage?: string;
    waitForExecution?: boolean;
}

Represents a command that can be executed in a terminal.

Type declaration

  • Optional args?: string[]

    The arguments required by the command.

  • Optional callback?: Awaitable<void>

    A callback function that is called when execution of the command is complete.

  • Optional description?: string

    The description of the command.

  • handler: CommandHandler

    The handler function that is called when the command is executed.

    Param: args

    The command arguments

    Param: command

    The command being executed.

  • name: string

    The name of the command.

  • Optional onError?: CommandErrorHandler

    The error handler function that is called when an error occurs during command execution.

    Param: args

    The command arguments

    Param: command

    The command being executed.

  • Optional usage?: string

    The usage instructions for the command.

  • Optional waitForExecution?: boolean

    Specifies whether the command should wait for execution to complete before returning.

Remarks

The Command interface defines the properties and methods required for a command in a terminal.

Example

const command: Command = {
name: 'ls',
description: 'List files and directories',
usage: 'ls [options] [path]',
args: ['options', 'path'],
waitForExecution: true,
handler: (args, command) => {
// Command execution logic
},
onError: (args, command) => {
// Error handling logic
},
};

Generated using TypeDoc