Skip to content

Commit 0c3f643

Browse files
committed
Add --json flag documentation for CLI commands
Document the new --json flag that outputs results in machine-readable JSON format: - Add --json to Universal Flags in CLI overview - Add JSON Output sections to deploy and run command docs with examples
1 parent 5b16c5b commit 0c3f643

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

documentation/cli/00_overview.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,13 @@ Specifies the path to Leo program root folder. Defaults to `./`.
6262

6363
#### `--home <HOME>`
6464
Specifies the path to the `.aleo` program registry. This is where programs downloaded from the network will be cached. Defaults to `~/.aleo/registry`.
65+
66+
#### `--json`
67+
Outputs results as JSON to stdout. Implies `-q` (suppresses normal CLI output).
68+
69+
Supported commands: `run`, `execute`, `test`, `deploy`, `upgrade`, `query`, `synthesize`.
70+
71+
**Example - piping to a file:**
72+
```bash
73+
leo run --json main 1u32 2u32 > output.json
74+
```

documentation/cli/06_deploy.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,33 @@ Once it is deployed, it CANNOT be changed.
7777

7878
See the **[Deploying](./../guides/03_deploying.md)** guide for more details.
7979

80+
### JSON Output
81+
82+
Use the `--json` flag to output results in JSON format for programmatic use:
83+
84+
```bash
85+
leo deploy --json -y
86+
```
87+
88+
```json
89+
{
90+
"deployments": [
91+
{
92+
"program_id": "my_program.aleo",
93+
"transaction_id": "at1..."
94+
}
95+
]
96+
}
97+
```
98+
99+
This is useful for scripting and CI/CD pipelines:
100+
```bash
101+
# Deploy and extract the transaction ID
102+
leo deploy --json -y | jq '.deployments[0].transaction_id'
103+
104+
# Deploy and save full output to a file
105+
leo deploy --json -y > deployment_result.json
106+
```
80107

81108
### Flags:
82109

0 commit comments

Comments
 (0)