From ebeba23c5dd413e3c50676ba0282462c3f20184b Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 21 Jun 2023 01:10:18 -0400 Subject: [PATCH] cli work --- Cargo.lock | 31 ++++++++---------------- external/cursive-flexi-logger-view | 2 +- veilid-cli/src/ui.rs | 39 +++++++++++++----------------- 3 files changed, 28 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb5dc00c..7de49121 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1502,7 +1502,7 @@ dependencies = [ "flexi_logger", "lazy_static", "log", - "time 0.3.22", + "time 0.3.9", "unicode-width", ] @@ -1544,7 +1544,7 @@ dependencies = [ "owning_ref", "serde_json", "serde_yaml", - "time 0.3.22", + "time 0.3.9", "tokio 1.28.2", "toml 0.7.4", "unicode-segmentation", @@ -2055,7 +2055,7 @@ dependencies = [ "regex", "rustversion", "thiserror", - "time 0.3.22", + "time 0.3.9", ] [[package]] @@ -5311,7 +5311,7 @@ checksum = "acee08041c5de3d5048c8b3f6f13fafb3026b24ba43c6a695a0c76179b844369" dependencies = [ "log", "termcolor", - "time 0.3.22", + "time 0.3.9", ] [[package]] @@ -5662,24 +5662,16 @@ dependencies = [ [[package]] name = "time" -version = "0.3.22" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" +checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" dependencies = [ "itoa", "libc", "num_threads", - "serde", - "time-core", - "time-macros 0.2.9", + "time-macros 0.2.4", ] -[[package]] -name = "time-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" - [[package]] name = "time-macros" version = "0.1.1" @@ -5692,12 +5684,9 @@ dependencies = [ [[package]] name = "time-macros" -version = "0.2.9" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" -dependencies = [ - "time-core", -] +checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" [[package]] name = "time-macros-impl" @@ -6009,7 +5998,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" dependencies = [ "crossbeam-channel", - "time 0.3.22", + "time 0.3.9", "tracing-subscriber", ] diff --git a/external/cursive-flexi-logger-view b/external/cursive-flexi-logger-view index effa60ce..1eaa0814 160000 --- a/external/cursive-flexi-logger-view +++ b/external/cursive-flexi-logger-view @@ -1 +1 @@ -Subproject commit effa60cea24e99f294865ed325ffc57612d72785 +Subproject commit 1eaa0814e0dd7e585b50c5d4e6e7cb9474d7a758 diff --git a/veilid-cli/src/ui.rs b/veilid-cli/src/ui.rs index 177407ee..8ea3ab9e 100644 --- a/veilid-cli/src/ui.rs +++ b/veilid-cli/src/ui.rs @@ -345,18 +345,19 @@ impl UI { return; } // run command - cursive_flexi_logger_view::push_to_log(StyledString::styled( + + cursive_flexi_logger_view::parse_lines_to_log( + ColorStyle::primary().into(), format!("> {}", text), - ColorStyle::primary(), - )); + ); match Self::run_command(s, text) { Ok(_) => {} Err(e) => { let color = *Self::inner_mut(s).log_colors.get(&Level::Error).unwrap(); - cursive_flexi_logger_view::push_to_log(StyledString::styled( + cursive_flexi_logger_view::parse_lines_to_log( + color.into(), format!(" Error: {}", e), - color, - )); + ); } } // save to history unless it's a duplicate @@ -459,16 +460,16 @@ impl UI { // X11/Wayland/other system copy if clipboard.set_text(text.as_ref()).is_ok() { let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap(); - cursive_flexi_logger_view::push_to_log(StyledString::styled( + cursive_flexi_logger_view::parse_lines_to_log( + color.into(), format!(">> Copied: {}", text.as_ref()), - color, - )); + ); } else { let color = *Self::inner_mut(s).log_colors.get(&Level::Warn).unwrap(); - cursive_flexi_logger_view::push_to_log(StyledString::styled( + cursive_flexi_logger_view::parse_lines_to_log( + color.into(), format!(">> Could not copy to clipboard"), - color, - )); + ); } } else { // OSC52 clipboard copy for terminals @@ -484,10 +485,10 @@ impl UI { { if std::io::stdout().flush().is_ok() { let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap(); - cursive_flexi_logger_view::push_to_log(StyledString::styled( + cursive_flexi_logger_view::parse_lines_to_log( + color.into(), format!(">> Copied: {}", text.as_ref()), - color, - )); + ); } } } @@ -1024,13 +1025,7 @@ impl UISender { { let inner = self.inner.lock(); let color = *inner.log_colors.get(&log_color).unwrap(); - let mut starting_style: Style = color.into(); - for line in event.lines() { - let (spanned_string, end_style) = - cursive::utils::markup::ansi::parse_with_starting_style(starting_style, line); - cursive_flexi_logger_view::push_to_log(spanned_string); - starting_style = end_style; - } + cursive_flexi_logger_view::parse_lines_to_log(color.into(), event); } let _ = self.cb_sink.send(Box::new(UI::update_cb)); }