Skip to content

Commit d080d06

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 d080d06

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-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

documentation/cli/12_run.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@ won't attempt to parse them as options:
4444
leo run <TRANSITION_NAME> -- <INPUT_0> -- <INPUT_1> ...
4545
```
4646

47+
### JSON Output
48+
49+
Use the `--json` flag to output results in JSON format for programmatic use:
50+
51+
```bash
52+
leo run --json main 1u32 2u32
53+
```
54+
55+
```json title="sample JSON output:"
56+
{
57+
"program": "my_program.aleo",
58+
"function": "main",
59+
"outputs": ["3u32"]
60+
}
61+
```
62+
63+
You can pipe the output to a file or use tools like `jq`:
64+
```bash
65+
leo run --json main 1u32 2u32 > result.json
66+
leo run --json main 1u32 2u32 | jq '.outputs[0]'
67+
```
68+
4769
### Flags:
4870
```
4971
--offline

0 commit comments

Comments
 (0)