Commands - egodigital/vscode-powertools GitHub Wiki
To enhance your editor, you can register custom commands, which can be used from anywhere in the editor, by using the API, e.g.
Create a commands section to the settings.json file in the .vscode sub folder of your workspace and add one or more entry:
{
    "ego.power-tools": {
        "commands": {
            "myCommand": {
                "script": "my_command.js",
                "button": {
                    "text": "Click here to start the command."
                }
            }
        }
    }
}For that example, create a my_command.js file in your .vscode folder and use the following skeleton:
exports.execute = async (args) => {
    // args => https://egodigital.github.io/vscode-powertools/api/interfaces/_contracts_.workspacecommandscriptarguments.html
    // s. https://code.visualstudio.com/api/references/vscode-api
    const vscode = args.require('vscode');
    vscode.window.showInformationMessage(
        `Hello, from '${ args.command }'!`
    );
};
| Name | Description | Required? | 
|---|---|---|
| button | Defines an optional button, which executes the command. | no | 
| description1 | A description for the command. | no | 
| forFile | Indicates if that command can be executed for a current or selected file or not (s. File explorer and context menus). Default: (false) | no | 
| forFolder | Indicates if that command can be executed for a current or selected folder or not (s. File explorer and context menus). Default: (false) | no | 
| if | (JavaScript) Code that checks if command is available or not. s. Conditional Settings | no | 
| ifFile | The regular expression, that checks if that button should be visible for an active editor or not. Path separators will always be converted to /, even in Windows. | no | 
| importValues | Defines a list of properties, which uses (external) values for itself. s. Import Settings | no | 
| name1 2 | The (display) name for the GUI. | no | 
| onCreated | The (JavaScript) code to executed after command has been created. s. Executable Settings | no | 
| onDestroyed | The (JavaScript) code to executed after command has been destroyed. s. Executable Settings | no | 
| options | Options for the script. | no | 
| platforms | A list of one or more platform IDs, where the button should be available on. s. process.platform | no | 
| script1 | The path to the script that should be invoked. Relative paths will be mapped to the .vscodesub folder of the workspace or the.vscode-powertoolssub folder inside the current user's home directory. | yes | 
1 supports placeholders
2 supports icons
| Name | Description | Required? | 
|---|---|---|
| color1 | The RGB text color. | no | 
| isRight | Display button one the right side or not. Default: (false) | no | 
| onEditorChanged | The (JavaScript) code to executed after active editor has changed. s. Executable Settings | no | 
| priority | A (numeric) value that defines the priority, the button should be displayed with. | no | 
| text1 2 | The (display) text. | no | 
| tooltip1 | The tooltip text. | no | 
1 supports placeholders
2 supports icons
If you want to make one or more commands available in an active editor, the file explorer or a context menu of an editor, set forFile and/or forFolder to (true).
Choose Execute Power Command (or Power Tools: Execute Power Command from command palette) to execute a command.

For example, add the following entry to your settings.json inside your workspace's sub folder .vscode:
{
    "ego.power-tools": {
        "commands": {
            "myCommand": {
                "script": "my_command.js",
                "forFile": true,
                "forFolder": true
            }
        }
    }
}Then create a my_command.js file in the same directory and use the following skeleton:
exports.execute = async (args) => {
    // args => (if file) https://egodigital.github.io/vscode-powertools/api/interfaces/_contracts_.workspacecommandscriptargumentsforfiles.html
    //         (if folder) https://egodigital.github.io/vscode-powertools/api/interfaces/_contracts_.workspacecommandscriptargumentsforfolders.html
    // https://code.visualstudio.com/api/references/vscode-api
    const vscode = args.require('vscode');
    if (args.file) {
        // file => vscode.Uri
        vscode.window.showInformationMessage(
            `File: '${ args.file }'`
        );
    } else if (args.folder) {
        // folder => vscode.Uri
        vscode.window.showInformationMessage(
            `Folder: '${ args.folder }'`
        );   
    }
};