From 3981cd90f8d46bf813677cc517bf36e25d04b210 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 27 Oct 2021 16:09:05 -0700 Subject: [PATCH] cli: use bright colors for head of operation log --- src/commands.rs | 12 ++++++++++-- src/formatter.rs | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index de19c5471..ec5da9cc8 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -3216,9 +3216,10 @@ fn cmd_op_log( formatter.write_str(&metadata.description)?; formatter.remove_label()?; for (key, value) in &metadata.tags { + formatter.add_label("tags".to_string())?; formatter.write_str(&format!("\n{}: {}", key, value))?; + formatter.remove_label()?; } - Ok(()) } } @@ -3234,18 +3235,25 @@ fn cmd_op_log( for parent in op.parents() { edges.push(Edge::direct(parent.id().clone())); } + let is_head_op = op.id() == &head_op_id; let mut buffer = vec![]; { let writer = Box::new(&mut buffer); let mut formatter = ui.new_formatter(writer); formatter.add_label("op-log".to_string())?; + if is_head_op { + formatter.add_label("head".to_string())?; + } template.format(&op, formatter.as_mut())?; + if is_head_op { + formatter.remove_label()?; + } formatter.remove_label()?; } if !buffer.ends_with(b"\n") { buffer.push(b'\n'); } - let node_symbol = if op.id() == &head_op_id { b"@" } else { b"o" }; + let node_symbol = if is_head_op { b"@" } else { b"o" }; graph.add_node(op.id(), &edges, node_symbol, &buffer)?; } diff --git a/src/formatter.rs b/src/formatter.rs index 5be86b87e..fc3af5c57 100644 --- a/src/formatter.rs +++ b/src/formatter.rs @@ -169,6 +169,13 @@ fn config_colors(user_settings: &UserSettings) -> HashMap { result.insert(String::from("op-log id"), String::from("blue")); result.insert(String::from("op-log user"), String::from("yellow")); result.insert(String::from("op-log time"), String::from("magenta")); + result.insert(String::from("op-log tags"), String::from("white")); + + result.insert(String::from("op-log head id"), String::from("bright blue")); + result.insert(String::from("op-log head user"), String::from("bright yellow")); + result.insert(String::from("op-log head time"), String::from("bright magenta")); + result.insert(String::from("op-log head description"), String::from("bright white")); + result.insert(String::from("op-log head tags"), String::from("bright white")); result.insert(String::from("concepts heading"), String::from("yellow"));