diff --git a/cli/src/main.rs b/cli/src/main.rs index 2e0134dc..854060d4 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -9,7 +9,10 @@ use std::{ use async_std::sync::Arc; use clap::{Args, CommandFactory, Parser, Subcommand}; -use color_eyre::{eyre, eyre::Context}; +use color_eyre::{ + eyre::{self, Context}, + owo_colors::OwoColorize, +}; use completer::enter_code; use console::{style, Term}; use futures::{future::Either, Future, FutureExt}; @@ -734,7 +737,7 @@ fn create_progress_bar(file_size: u64) -> ProgressBar { pb.set_style( ProgressStyle::default_bar() // .template("[{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})") - .template("[{elapsed_precise}] [{wide_bar}] {bytes}/{total_bytes} ({eta})") + .template("[{elapsed_precise:.yellow}] [{wide_bar}] {bytes:.blue}/{total_bytes:.blue} {decimal_bytes_per_sec:.cyan} ({eta:.yellow})") .unwrap() .progress_chars("#>-"), ); @@ -748,6 +751,7 @@ fn create_progress_handler(pb: ProgressBar) -> impl FnMut(u64, u64) { pb.set_length(total); pb.enable_steady_tick(std::time::Duration::from_millis(250)); } + pb.set_position(sent); } } @@ -1020,12 +1024,12 @@ async fn receive_inner_v1( || util::ask_user( format!( "Receive file '{}' ({})?", - req.file_name(), + req.file_name().green(), match NumberPrefix::binary(req.file_size() as f64) { NumberPrefix::Standalone(bytes) => format!("{} bytes", bytes), - NumberPrefix::Prefixed(prefix, n) => - format!("{:.1} {}B in size", n, prefix.symbol()), - }, + NumberPrefix::Prefixed(prefix, n) => format!("{:.1} {}B", n, prefix.symbol()), + } + .blue(), ), true, ) @@ -1060,7 +1064,7 @@ async fn receive_inner_v1( /* If there is a collision, ask whether to overwrite */ if !util::ask_user( - format!("Override existing file {}?", file_path.display()), + format!("Override existing file {}?", file_path.display()).red(), false, ) .await @@ -1184,6 +1188,14 @@ async fn receive_inner_v2( fn transit_handler(info: TransitInfo) { tracing::info!("{info}"); + let mut term = Term::stdout(); + + let _ = writeln!( + term, + "Connecting {} to {}", + info.conn_type.bright_magenta(), + info.peer_addr.cyan() + ); } #[cfg(test)] diff --git a/src/transit.rs b/src/transit.rs index e0edc881..a5e9539b 100644 --- a/src/transit.rs +++ b/src/transit.rs @@ -665,6 +665,16 @@ pub enum ConnectionType { }, } +impl std::fmt::Display for ConnectionType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ConnectionType::Direct => write!(f, "directly"), + ConnectionType::Relay { name: Some(name) } => write!(f, "via relay ({})", name), + ConnectionType::Relay { name: None } => write!(f, "via relay"), + } + } +} + /// Metadata for the established transit connection #[derive(Clone, Debug, Eq, PartialEq)] #[non_exhaustive]