aboutsummaryrefslogtreecommitdiffstats
path: root/examples/zot
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2019-06-10 14:21:09 +0200
committerHarald Eilertsen <haraldei@anduin.net>2019-06-10 14:21:09 +0200
commit39bef981a13701aaca944e50c5354487d528d977 (patch)
tree2e3da2b1e760bdfadbb03c66cb9cfa362b9909e5 /examples/zot
parentc9ac54435649973c1aa0543434cc344e66cf33f8 (diff)
downloadrust-zotapi-39bef981a13701aaca944e50c5354487d528d977.tar.gz
rust-zotapi-39bef981a13701aaca944e50c5354487d528d977.tar.bz2
rust-zotapi-39bef981a13701aaca944e50c5354487d528d977.zip
zotcli: Make group formatting work and print flags.
Formatting requires the format arguments to be proper strings or integers. Formatting a serde_json::Value directly did not work.
Diffstat (limited to 'examples/zot')
-rw-r--r--examples/zot/group.rs25
1 files changed, 20 insertions, 5 deletions
diff --git a/examples/zot/group.rs b/examples/zot/group.rs
index 71f60d6..6bb3839 100644
--- a/examples/zot/group.rs
+++ b/examples/zot/group.rs
@@ -24,11 +24,26 @@ pub fn list(data: &str) {
println!("----+------------------+-----+-------+-------------------------");
for group in groups {
- println!("{:4} | {:16} | {:3} | | {}",
- group["id"],
- group["gname"],
- group["uid"],
- group["hash"])
+ let mut flags = String::new();
+
+ if let Some(visible) = group["visible"].as_u64() {
+ if visible != 0 {
+ flags += "v";
+ }
+ }
+
+ if let Some(deleted) = group["deleted"].as_u64() {
+ if deleted != 0 {
+ flags += "d";
+ }
+ }
+
+ print!("{:>3} | {:16} | {:>3} | {:5} | {}\n",
+ group["id"].as_u64().unwrap(),
+ group["gname"].as_str().unwrap(),
+ group["uid"].as_u64().unwrap(),
+ flags,
+ group["hash"].as_str().unwrap());
}
}
else {