Skip to main content

Command

Overview

Command is used to run straightforward, fire and forget piece of code.

Plugin Manifest

To use commands, entrypoint with type "command" is required

Example

[[entrypoint]]
id = 'main'
name = 'Main'
path = 'src/main.tsx'
type = 'command'
description = 'Description of a command'

Note on usage of async

JavaScript is a single-threaded language, at any time only one chunk of code is being executed.

This has implications on Gauntlet plugins.

Let's say in the same plugin you have 2 entrypoints: view and command, let's also say that your command entrypoint needs to scan some directories. If you are using synchronous versions of functions to access file system, user will not be able to open any views because JS runtime is being busy with scanning directories. For this reason prefer using async versions of APIs where possible, or if your code is computationally intensive, offload the computation to a worker

Examples

Simple

export default async function Command() {
console.log("Running the Gauntlet...")
}

Preferences

import { CommandContext } from "@project-gauntlet/api/helpers";

type PluginCommandContext = CommandContext<{ testBool: boolean }, { testStr: string }>;

export default async function Command({ pluginPreferences, entrypointPreferences }: PluginCommandContext) {
console.log(pluginPreferences.testBool);
console.log(entrypointPreferences.testStr);
}