Skip to content

Commit dcc7347

Browse files
committed
Readme: Add documentation for script inputs
1 parent 80a65e3 commit dcc7347

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

README.md

+37-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ The following parameters are available to customize your Script Command in Rayca
5858
| icon | Icon that is displayed in the root search. Can be an emoji, a file path (relative or full) or a remote URL (only https). Supported formats for images are PNG and JPEG. Please make sure to use small icons, recommended size - 32px. | No | 0.29+ |
5959
| currentDirectoryPath | Path from which the script is executed. Default is the path of the script. | No | 0.29+ |
6060
| needsConfirmation | Specify `true` if you would like to show confirmation alert dialog before running the script. Can be helpful with destructive scripts like "Quit All Apps" or "Empty Trash". Default value is `false`. | No | 0.30+ |
61-
| refreshTime | Specify a refresh interval for `inline` mode scripts in seconds, minutes, hours or days. Examples: `5s`, `1m`, `12h`, `1d`. Script output will be shown inline in dashboard items. *Note* that the actual times are not accurate and can vary depending on how the OS prioritizes scheduled work. The minimum allowed refresh interval is 5 seconds (use responsibly...), and the maximum allowed number of refreshing `inline` commands is 10. | No | 0.31+ |
62-
| author | Define an author name to be part of the script commands documentation | No | |
63-
| authorURL | Author social media, website, email or anything to help the users to get in touch | No | |
64-
| description | A brief description about the script command to be presented in the documentation | No | |
61+
| refreshTime | Specify a refresh interval for `inline` mode scripts in seconds, minutes, hours or days. Examples: `5s`, `1m`, `12h`, `1d`. Script output will be shown inline in dashboard items. *Note* that the actual times are not accurate and can vary depending on how the OS prioritizes scheduled work. The minimum allowed refresh interval is 5 seconds (use responsibly...), and the maximum allowed number of refreshing `inline` commands is 10. | No | 0.31+ |
62+
| argument[1...3] | Custom arguments, see [Passing Arguments](https://github.com/raycast/script-commands#how-to-use-this-repository) section that explains in details how to use this field | No | 1.2.0+ |
63+
| author | Define an author name to be part of the script commands documentation | No | |
64+
| authorURL | Author social media, website, email or anything to help the users to get in touch | No | |
65+
| description | A brief description about the script command to be presented in the documentation | No | |
66+
6567

6668
**⚠️ Whenever you make changes to the parameters of the Script Command, trigger the "Reload Script Directories" command in root search (v0.33+), or press "Reload" in script commands preferences, or activate "Auto Reload" in preferences so that your scripts get automatically reloaded (experimental, v0.33+). Also note that "reloading" means that script metadata is parsed and Raycast search is refreshed – the actual scripts are only run when you manually trigger their command or when an inline command with refreshTime is automatically triggered.**
6769

@@ -75,6 +77,37 @@ In `fullOutput` the entire output is presented on a separate view, similar to a
7577

7678
In `inline` mode, the first line of output will be directly shown in the command item and automatically refresh according to the specified `refreshTime`. Tip: Set your dashboard items as favorites via the action menu in Raycast
7779

80+
### Passing Arguments
81+
82+
![Custom Arguments](https://github.com/raycast/script-commands/blob/master/screenshots/custom-arguments.png?raw=true)
83+
84+
Use `argument[1..3]` metadata to specify custom arguments that will be displayed as inputs in the search bar when the script is selected. Value of the argument metadata paratmeter should be valid json with these fields:
85+
86+
| Field | Description | Required | App Version |
87+
|---------------|-------------------------------------------------|----------|-------------|
88+
| type | Input type. For now only "text" value available.| Yes | 1.2.0+ |
89+
| placeholder | Placeholder for the input field. | Yes | 1.2.0+ |
90+
91+
**Maximum number of arguments:** 3 (if you feel like it's not enough for your use case, please let is know via feedback or in the Slack community)
92+
93+
Here's an example of a simple web search script with two arguments:
94+
```bash
95+
#!/bin/bash
96+
97+
# Required parameters:
98+
# @raycast.schemaVersion 1
99+
# @raycast.title Search Flights
100+
# @raycast.mode silent
101+
102+
# Optional parameters:
103+
# @raycast.icon 🛩
104+
# @raycast.packageName Web Searches
105+
# @raycast.argument1 { "type": "text", "placeholder": "from city" }
106+
# @raycast.argument2 { "type": "text", "placeholder": "to city" }
107+
108+
open "https://www.google.com/search?q=flights from $1 to $2"
109+
```
110+
78111
### Error Handling
79112

80113
If the script exits with a status code not equal to 0, Raycast interprets it as failed and shows a toast that the script failed to run.

screenshots/custom-arguments.png

780 KB
Loading

0 commit comments

Comments
 (0)