summaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-02-06 15:28:27 +0100
committerJustus Winter <justus@sequoia-pgp.org>2018-02-06 15:28:27 +0100
commit73c02452ee5a8d29c5df5c67cd775755b3b8d64c (patch)
tree2b83a4b867258e2476bee7448a8f0bb218b25f6f /tool
parenta63fa8574b8fafd7c15c9f0045334cf5fdb0354a (diff)
tool: Improve log display.
- Do not provide slug when listing entries related to a specific binding.
Diffstat (limited to 'tool')
-rw-r--r--tool/src/main.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/tool/src/main.rs b/tool/src/main.rs
index 738d2063..c96178fd 100644
--- a/tool/src/main.rs
+++ b/tool/src/main.rs
@@ -361,9 +361,9 @@ fn real_main() -> Result<(), failure::Error> {
if m.is_present("label") {
let binding = store.lookup(m.value_of("label").unwrap())
.context("No such key")?;
- print_log(binding.log().context("Failed to get log")?);
+ print_log(binding.log().context("Failed to get log")?, false);
} else {
- print_log(store.log().context("Failed to get log")?);
+ print_log(store.log().context("Failed to get log")?, true);
}
},
_ => {
@@ -419,7 +419,7 @@ fn real_main() -> Result<(), failure::Error> {
table.printstd();
},
("log", Some(_)) => {
- print_log(Store::server_log(&ctx)?);
+ print_log(Store::server_log(&ctx)?, true);
},
_ => {
eprintln!("No list subcommand given.");
@@ -449,16 +449,22 @@ fn list_bindings(store: &Store) -> Result<(), failure::Error> {
Ok(())
}
-fn print_log(iter: LogIter) {
+fn print_log(iter: LogIter, with_slug: bool) {
let mut table = Table::new();
table.set_format(*prettytable::format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
- table.set_titles(row!["timestamp", "slug", "message"]);
+ let mut head = row!["timestamp", "message"];
+ if with_slug {
+ head.insert_cell(1, Cell::new("slug"));
+ }
+ table.set_titles(head);
for entry in iter {
- table.add_row(Row::new(vec![
- Cell::new(&format_time(&entry.timestamp)),
- Cell::new(&entry.slug),
- Cell::new(&entry.short())]));
+ let mut row = row![&format_time(&entry.timestamp),
+ &entry.short()];
+ if with_slug {
+ row.insert_cell(1, Cell::new(&entry.slug));
+ }
+ table.add_row(row);
}
table.printstd();