Repository navigation
Command API
Federico Conticello edited this page Mar 24, 2026
·
1 revision
Plugins can execute external commands (linters, formatters, build tools) with user-approved permissions.
Runs an external command and returns the result.
local result = api:run_command("ruff", "check", "--output-format=json", file_path)
if result.success then
local output = result.stdout
-- parse output
else
api:log("Command failed: " .. result.stderr)
endA table with:
| Field | Type | Description |
|---|---|---|
stdout |
string | Captured standard output |
stderr |
string | Captured standard error |
success |
boolean |
true if exit code was 0 |
- Working directory is set to the project root (if detected)
- Timeout: 30 seconds — the process is killed after this
- Arguments are passed as separate values, not as a shell string
The command must be listed in [permissions] execute in your plugin.toml:
[permissions]
execute = ["ruff", "pyright"]On first run, FerrisPad prompts the user to approve the command. The user can:
- Allow — the command runs and is remembered for this plugin
- Deny — the command is blocked
Arguments are validated to block shell injection. These characters are forbidden:
; & | ` $ ( ) { } < > \n \r \ * ? [ ]
Checks if a command is available on the system PATH. Returns true or false.
if not api:command_exists("eslint") then
return {
status_message = {
level = "warning",
text = "ESLint not found. Install it with: npm install -g eslint"
}
}
endThis does not require any permissions — it only checks existence, not execution.