Arguments
Last updated
Last updated
Raycast supports arguments for your commands so that users can enter values right from Root Search before opening the command.
Arguments are configured in the manifest per command.
Maximum number of arguments: 3 (if you have a use case that requires more, please let us know via feedback or in the Slack community)
The order of the arguments specified in the manifest is important and is reflected by the fields shown in Root Search. To provide a better UX, put the required arguments before the optional ones.
Let's say we want a command with three arguments. Its package.json
will look like this:
The command itself will receive the arguments' values via the arguments
prop:
A command receives the values of its arguments via a top-level prop named arguments
. It is an object with the arguments' name
as keys and their values as the property's values.
Depending on the type
of the argument, the type of its value will be different.
text
string
password
string
dropdown
string
Raycast provides a global TypeScript namespace called Arguments
which contains the types of the arguments of all the commands of the extension.
For example, if a command named show-todos
accepts arguments, its LaunchProps
can be described as LaunchProps<{ arguments: Arguments.ShowTodos }>
. This will make sure that the types used in the command stay in sync with the manifest.