diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ae3d7f..843cca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ User-visible changes to `voltage`, newest first. Each pull request that changes ## Unreleased +- `-o` is short for `--output`, as in `voltage wallets list -o json`. + ## 0.2.0 - 2026-10-22 Commands that change something now only describe the change (exit code 6) unless `--execute` or `VOLTAGE_EXECUTE=1` asks to send them: add one of them to scripts that send payments or make other changes. Also new: `voltage context`, interactive pickers, `--no-input` and `--quiet`, and errors that name the next command. diff --git a/docs/reference/global-flags.md b/docs/reference/global-flags.md index 93cf9c3..4354655 100644 --- a/docs/reference/global-flags.md +++ b/docs/reference/global-flags.md @@ -20,7 +20,7 @@ Generated from the command definitions by `VOLTAGE_BLESS=1 cargo test`; do not e | Flag | Meaning | |---|---| | `--json` | Write a stable JSON result envelope | -| `--output OUTPUT` | Output format (`table`, `json`, `ndjson`) | +| `-o`, `--output OUTPUT` | Output format (`table`, `json`, `ndjson`) | | `--output-file PATH` | Save the complete response to a new owner-only file | | `--show-secrets` | Explicitly allow secrets in result output | | `-q`, `--quiet` | Hide optional progress and notices, not errors, results, or recovery IDs | diff --git a/src/cli.rs b/src/cli.rs index d368291..a6e5280 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -55,7 +55,7 @@ pub struct GlobalFlags { #[arg(long, global = true, help_heading = "Output")] pub json: bool, /// Output format - #[arg(long, global = true, value_enum, help_heading = "Output")] + #[arg(short = 'o', long, global = true, value_enum, help_heading = "Output")] pub output: Option, /// Save the complete response to a new owner-only file #[arg(long, global = true, value_name = "PATH", help_heading = "Output")] @@ -1381,6 +1381,17 @@ mod tests { ); } + #[test] + fn short_o_selects_the_output_format_before_or_after_the_subcommand() { + for args in [ + ["voltage", "-o", "json", "wallets", "list"], + ["voltage", "wallets", "list", "-o", "json"], + ] { + let invocation = Invocation::try_parse_from(args).unwrap(); + assert_eq!(invocation.global.output, Some(OutputFormat::Json)); + } + } + #[test] fn global_flags_work_after_subcommand() { let invocation = Invocation::try_parse_from([