Skip to content

1.1 Docs: Commands

Louis Stanko edited this page Nov 20, 2020 · 1 revision

Commands

Here you can read how to add new custom commands to your terminal, how to customize and what else you can do. If you want to change the initial behavior you can modify the CMDs class in core.ts.

Add your own command

Commands.add(
    'commandName', //! case-sensitive
    (path: Path, args: string[]): string => {
        // path - active directory
        // args[0] - command
        // args[1..] - first, second, ... argument and so on

        return 'this is an <b>html</b> string which will be written to the stdout.';
    },
    'a short description of your command' // (optional) description of your command
)

Get all commands

Returns all commands

Commands.all() // returns {object} all commands as an object
               // pass by reference so direct modification is possible

Get all command names

Returns an array of all registered commands

Commands.keys() // returns {string[]} all command names

Find command by name

Returns the description and function of the command

Commands.find(name: string) // returns {object|undefined}
                            // pass by reference so direct modification is possible
                            // param {string} name - the name of the command

Remove preexisting commands

  1. Go to init.ts
  2. Edit the first argument of new CMDs({ ... }). Delete the object wich has the command you don't want anymore.