Skip to content

Commit 83a298f

Browse files
committed
docs: Add CLI direct shortcuts and machine-mode flag
Documents top-level shortcuts (-sql, -p / -chat) and the global --machine / --programmatic flag introduced in spiceai/spiceai#10815. Source: spiceai/spiceai#10815
1 parent 72fa531 commit 83a298f

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

website/docs/cli/index.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,51 @@ Common commands are:
8484

8585
See [Spice CLI command reference](./reference) for the full list of available commands.
8686

87+
## Direct Command Shortcuts
88+
89+
For quick scripting and shell workflows, the CLI accepts top-level shortcuts that skip the subcommand name:
90+
91+
| Shortcut | Equivalent | Description |
92+
| ----------------------- | ----------------------------------- | -------------------------------------- |
93+
| `spice -sql <query>` | `spice sql --query <query>` | Run a single SQL statement and exit. |
94+
| `spice -p <prompt>` | `spice chat <prompt>` (one-shot) | Send a single chat prompt and exit. |
95+
| `spice -chat <prompt>` | `spice chat <prompt>` (one-shot) | Alias for `-p`. |
96+
97+
The shortcut consumes the first non-flag argument as the value; any other flags (including global flags such as `--cloud`, `--api-key`, `--endpoint`, and `--machine`) are forwarded to the underlying command. Use `--` to terminate flag parsing when the prompt or query begins with a `-`.
98+
99+
```bash
100+
# One-shot SQL against the local runtime
101+
spice -sql "select count(*) from taxi_trips"
102+
103+
# One-shot chat prompt
104+
spice -p "summarize the orders table"
105+
106+
# Same against Spice.ai Cloud
107+
spice --cloud --api-key $SPICE_KEY -sql "select 1"
108+
```
109+
110+
## Machine-readable Mode
111+
112+
Pass `--machine` (alias `--programmatic`) as a global flag to make the CLI output JSON wherever supported and emit structured JSON for errors. This is intended for LLM agents, CI scripts, and other automation that needs to parse `spice` output reliably.
113+
114+
```bash
115+
# Default human output
116+
spice version
117+
118+
# Same command, JSON output for automation
119+
spice --machine version
120+
121+
# Works with subcommands
122+
spice --machine status
123+
spice --machine query list
124+
spice --machine cloud secrets list
125+
126+
# Combine with direct shortcuts
127+
spice --machine -sql "select 1"
128+
```
129+
130+
`--machine` is global and may appear before or after the subcommand (`spice status --machine` is also valid). When set, mutating commands that support JSON output also default to JSON, and clap parsing errors are emitted as JSON to stderr.
131+
87132
## Updating
88133

89134
To update to latest CLI, run the upgrade command.

0 commit comments

Comments
 (0)