Skip to content

Commit a78cc3b

Browse files
committed
Merge #212: feat(pretty-format): add pretty flag to format outputs in a tabular form
94012c6 feat(pretty-fmt): update README for `pretty` flag (Vihiga Tyonum) 1cadf63 feat(pretty-fmt): add cli-table to format output (Vihiga Tyonum) Pull request description: Fixes #193 <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description This PR adds a top level flag `--pretty` to format output in a tabular form to enhance readability for users. <!-- Describe the purpose of this PR, what's being adding and/or fixed --> ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ## Changelog notice - Add `--pretty` top level flag for formatting commands output in a tabular format ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [ ] I've added tests for the new feature * [x] I've added docs for the new feature * [x] I've updated `CHANGELOG.md` Top commit has no ACKs. Tree-SHA512: 61dee251b2f3615ae013c31bcd484db7315ddab103a1668f8ca20d34337042bcc8ad48c5014029db5fecb6b5573c2c3ac9a2521e31678d851191841733bceafc
2 parents 67011b3 + 94012c6 commit a78cc3b

File tree

7 files changed

+509
-104
lines changed

7 files changed

+509
-104
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ page. See [DEVELOPMENT_CYCLE.md](DEVELOPMENT_CYCLE.md) for more details.
66
## [Unreleased]
77

88
- Removed MSRV and bumped Rust Edition to 2024
9+
- Add `--pretty` top level flag for formatting commands output in a tabular format
910

1011
## [1.0.0]
1112

Cargo.lock

Lines changed: 71 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ log = "0.4"
2020
serde_json = "1.0"
2121
thiserror = "2.0.11"
2222
tokio = { version = "1", features = ["full"] }
23+
cli-table = "0.5.0"
2324

2425
# Optional dependencies
2526
bdk_bitcoind_rpc = { version = "0.20.0", optional = true }

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,12 @@ Note: You can modify the `Justfile` to reflect your nodes' configuration values.
193193
cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password sync
194194
cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password balance
195195
```
196+
197+
## Formatting Responses using `--pretty` flag
198+
199+
You can optionally return outputs of commands in human-readable, tabular format instead of `JSON`. To enable this option, simply add the `--pretty` flag as a top level flag. For instance, you wallet's balance in a pretty format, you can run:
200+
201+
```shell
202+
cargo run --pretty -n signet wallet -w {wallet_name} -d sqlite balance
203+
```
204+
This is available for wallet, key, repl and compile features. When ommitted, outputs default to `JSON`.

src/commands.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ pub struct CliOpts {
5151
/// Default value : ~/.bdk-bitcoin
5252
#[arg(env = "DATADIR", short = 'd', long = "datadir")]
5353
pub datadir: Option<std::path::PathBuf>,
54+
/// Output results in pretty format (instead of JSON).
55+
#[arg(long = "pretty")]
56+
pub pretty: bool,
5457
/// Top level cli sub-commands.
5558
#[command(subcommand)]
5659
pub subcommand: CliSubCommand,

0 commit comments

Comments
 (0)