Skip to main content

Preferences

Overview

Preferences are a way for plugins to be configured. Value of preference can be changed in Settings UI.

There are 2 types of preferences: plugin (scoped to whole plugin) and entrypoint (specific to given entrypoint).

Preferences are defined in manifest. Preference can be defined with default value, if default value is not provided preference is considered to be required and user will be prompted before running the command or opening view to set preference value.

Currently supported types of values:

  • number
  • string
  • bool
  • enum (string, but only predefined list of values is allowed)
  • list of strings
  • list of numbers
  • list of enums
note

Currently, lists do not support specifying default value, and it will always be an empty list

Preferences In View

Example

import { ReactElement } from "react";
import { List } from "@project-gauntlet/api/components";
import { useEntrypointPreferences, usePluginPreferences } from "@project-gauntlet/api/hooks";

interface PluginPreferences {
testBool: boolean
}

interface EntrypointPreference {
testStr: string
}

export default function View(): ReactElement {
const pluginPreferences = usePluginPreferences<PluginPreferences>();
const entrypointPreferences = useEntrypointPreferences<EntrypointPreference>();

return (
<List>
<List.Item id="item" title={"Plugin - " + pluginPreferences.testBool}/>
<List.Item id="item" title={"Entrypoint - " + entrypointPreferences.testStr}/>
</List>
)
}

Preferences In Command

Example

See Preference Section on Command page for example

Preferences In Entrypoint Generator

Example

See Preference Section on Entrypoint Generator page for example