From 0c3f6433a4dd5802ae667bffcce3275c015e68ae Mon Sep 17 00:00:00 2001 From: JoshuaBatty Date: Wed, 17 Dec 2025 13:12:02 +1100 Subject: [PATCH 1/3] 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 --- documentation/cli/00_overview.md | 10 ++++++++++ documentation/cli/06_deploy.md | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/documentation/cli/00_overview.md b/documentation/cli/00_overview.md index d6f5b4e04..3c5e01b51 100644 --- a/documentation/cli/00_overview.md +++ b/documentation/cli/00_overview.md @@ -62,3 +62,13 @@ Specifies the path to Leo program root folder. Defaults to `./`. #### `--home ` Specifies the path to the `.aleo` program registry. This is where programs downloaded from the network will be cached. Defaults to `~/.aleo/registry`. + +#### `--json` +Outputs results as JSON to stdout. Implies `-q` (suppresses normal CLI output). + +Supported commands: `run`, `execute`, `test`, `deploy`, `upgrade`, `query`, `synthesize`. + +**Example - piping to a file:** +```bash +leo run --json main 1u32 2u32 > output.json +``` diff --git a/documentation/cli/06_deploy.md b/documentation/cli/06_deploy.md index 22a571db3..2e81f37f4 100644 --- a/documentation/cli/06_deploy.md +++ b/documentation/cli/06_deploy.md @@ -77,6 +77,33 @@ Once it is deployed, it CANNOT be changed. See the **[Deploying](./../guides/03_deploying.md)** guide for more details. +### JSON Output + +Use the `--json` flag to output results in JSON format for programmatic use: + +```bash +leo deploy --json -y +``` + +```json +{ + "deployments": [ + { + "program_id": "my_program.aleo", + "transaction_id": "at1..." + } + ] +} +``` + +This is useful for scripting and CI/CD pipelines: +```bash +# Deploy and extract the transaction ID +leo deploy --json -y | jq '.deployments[0].transaction_id' + +# Deploy and save full output to a file +leo deploy --json -y > deployment_result.json +``` ### Flags: From dd4984372b6f4f9f5fc0bd2844a14629ba2afd50 Mon Sep 17 00:00:00 2001 From: Joshua Batty Date: Mon, 5 Jan 2026 10:40:25 +1100 Subject: [PATCH 2/3] Update documentation/cli/00_overview.md Co-authored-by: Alexander Kim Signed-off-by: Joshua Batty --- documentation/cli/00_overview.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/cli/00_overview.md b/documentation/cli/00_overview.md index 3c5e01b51..2e396661a 100644 --- a/documentation/cli/00_overview.md +++ b/documentation/cli/00_overview.md @@ -68,7 +68,7 @@ Outputs results as JSON to stdout. Implies `-q` (suppresses normal CLI output). Supported commands: `run`, `execute`, `test`, `deploy`, `upgrade`, `query`, `synthesize`. -**Example - piping to a file:** -```bash + +```bash title="Example: Piping to a File" leo run --json main 1u32 2u32 > output.json ``` From d9a5cba1763457499c3966fdd4701ae22c6ce9d6 Mon Sep 17 00:00:00 2001 From: Joshua Batty Date: Fri, 9 Jan 2026 08:35:52 +1100 Subject: [PATCH 3/3] Update docs for --json-output flag (writes to disk) - Rename --json to --json-output - Document default output location (build/json-outputs/.json) - Document custom path option (--json-output=path) - Remove stdout piping examples (no longer needed) --- documentation/cli/00_overview.md | 16 +++++++++++----- documentation/cli/06_deploy.md | 14 ++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/documentation/cli/00_overview.md b/documentation/cli/00_overview.md index 2e396661a..9b4090901 100644 --- a/documentation/cli/00_overview.md +++ b/documentation/cli/00_overview.md @@ -63,12 +63,18 @@ Specifies the path to Leo program root folder. Defaults to `./`. #### `--home ` Specifies the path to the `.aleo` program registry. This is where programs downloaded from the network will be cached. Defaults to `~/.aleo/registry`. -#### `--json` -Outputs results as JSON to stdout. Implies `-q` (suppresses normal CLI output). +#### `--json-output[=]` +Saves structured JSON output to disk. -Supported commands: `run`, `execute`, `test`, `deploy`, `upgrade`, `query`, `synthesize`. +- **Default location**: `build/json-outputs/.json` +- **Custom path**: `--json-output=my-results.json` +Supported commands: `deploy`, `upgrade`, `run`, `execute`, `test`, `query`, `synthesize`. -```bash title="Example: Piping to a File" -leo run --json main 1u32 2u32 > output.json +```bash title="Examples" +# Save to default location (build/json-outputs/run.json) +leo run --json-output main 1u32 2u32 + +# Save to custom path +leo execute main --json-output=my-results.json ``` diff --git a/documentation/cli/06_deploy.md b/documentation/cli/06_deploy.md index 2e81f37f4..bffca3a21 100644 --- a/documentation/cli/06_deploy.md +++ b/documentation/cli/06_deploy.md @@ -79,12 +79,17 @@ See the **[Deploying](./../guides/03_deploying.md)** guide for more details. ### JSON Output -Use the `--json` flag to output results in JSON format for programmatic use: +Use `--json-output` to save structured JSON results to disk for programmatic use: ```bash -leo deploy --json -y +# Save to default location (build/json-outputs/deploy.json) +leo deploy --json-output -y + +# Save to custom path +leo deploy --json-output=deployment_result.json -y ``` +Example output (`build/json-outputs/deploy.json`): ```json { "deployments": [ @@ -99,10 +104,7 @@ leo deploy --json -y This is useful for scripting and CI/CD pipelines: ```bash # Deploy and extract the transaction ID -leo deploy --json -y | jq '.deployments[0].transaction_id' - -# Deploy and save full output to a file -leo deploy --json -y > deployment_result.json +jq '.deployments[0].transaction_id' build/json-outputs/deploy.json ``` ### Flags: