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
- src/preferences.tsx
- gauntlet.toml
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]]
id = 'testBool'
name = 'Test Boolean Preference'
type = 'bool'
default = true
description = ""
[[entrypoint]]
id = 'preferences'
name = 'Preferences'
path = 'src/preferences.tsx'
type = 'view'
description = ''
[[entrypoint.preferences]]
id = 'testStr'
name = 'Test String Preference'
type = 'string'
default = 'test_value'
description = ""
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