aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2023-07-21 10:37:36 +0200
committerIgor Pashev <pashev.igor@gmail.com>2023-07-22 13:04:54 +0200
commita68fff8ea021c3867139d82e858be1aa6343f3a3 (patch)
tree4fc6721cb78ff19bce8db4bc8a5bb3dfbaf98a5e /README.md
downloadrust-clap-output-formats-a68fff8ea021c3867139d82e858be1aa6343f3a3.tar.gz
Initial commitHEADmaster
Diffstat (limited to 'README.md')
-rw-r--r--README.md67
1 files changed, 67 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..10619d3
--- /dev/null
+++ b/README.md
@@ -0,0 +1,67 @@
+How to make CLI tools composing different output formats using [clap](https://crates.io/crates/clap).
+
+Demo:
+
+ $ ./target/debug/rust-clap-output-formats --help
+ Usage: rust-clap-output-formats <COMMAND>
+
+ Commands:
+ debug Debug output by default
+ text Text output by default
+ api Unformatted JSON output by default
+ json Pretty formatted JSON output by default
+ yaml YAML output by default
+ table Table output by default
+ help Print this message or the help of the given subcommand(s)
+
+ Options:
+ -h, --help Print help
+
+ $ ./target/debug/rust-clap-output-formats debug --help
+ Debug output by default
+
+ Usage: rust-clap-output-formats debug [OPTIONS]
+
+ Options:
+ --debug Display as internal debug representation
+ --text Display as text
+ --api Display as unformatted JSON
+ -h, --help Print help
+
+ $ ./target/debug/rust-clap-output-formats table --help
+ Table output by default
+
+ Usage: rust-clap-output-formats table [OPTIONS]
+
+ Options:
+ --table Display as table
+ --yaml Display as YAML
+ --json Display as pretty formatted JSON
+ --api Display as unformatted JSON
+ --text Display as text
+ --debug Display as internal debug representation
+ -h, --help Print help
+
+ $ ./target/debug/rust-clap-output-formats json
+ {
+ "name": "Hello",
+ "value": "world"
+ }
+
+ $ ./target/debug/rust-clap-output-formats table
+ +-------+-------+
+ | Name | Value |
+ +===============+
+ | Hello | world |
+ +-------+-------+
+
+ $ ./target/debug/rust-clap-output-formats table --json
+ {
+ "name": "Hello",
+ "value": "world"
+ }
+
+ $ ./target/debug/rust-clap-output-formats table --yaml
+ name: Hello
+ value: world
+