upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/lib/client.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/client.rs')
-rw-r--r--src/lib/client.rs33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/lib/client.rs b/src/lib/client.rs
index 4f5c341..1cb1a4a 100644
--- a/src/lib/client.rs
+++ b/src/lib/client.rs
@@ -455,7 +455,6 @@ impl Connect for Client {
455 let progress_reporter_clone = progress_reporter.clone(); 455 let progress_reporter_clone = progress_reporter.clone();
456 let total_relays_clone = total_relays; 456 let total_relays_clone = total_relays;
457 async move { 457 async move {
458 let dim = Style::new().color256(247);
459 let relay_column_width = request.relay_column_width; 458 let relay_column_width = request.relay_column_width;
460 459
461 let relay_url = request 460 let relay_url = request
@@ -467,10 +466,10 @@ impl Connect for Client {
467 let pb = progress_reporter_clone.add( 466 let pb = progress_reporter_clone.add(
468 ProgressBar::new(1) 467 ProgressBar::new(1)
469 .with_prefix( 468 .with_prefix(
470 dim.apply_to(format!( 469 format!(
471 "{: <relay_column_width$} connecting", 470 "{: <relay_column_width$} connecting",
472 &relay_url 471 &relay_url
473 )) 472 )
474 .to_string(), 473 .to_string(),
475 ) 474 )
476 .with_style(pb_style(current_timeout_clone.clone())?), 475 .with_style(pb_style(current_timeout_clone.clone())?),
@@ -681,6 +680,7 @@ impl Connect for Client {
681 format!("fetching... updates: {report}") 680 format!("fetching... updates: {report}")
682 }, 681 },
683 )) 682 ))
683 .for_stderr()
684 .to_string(), 684 .to_string(),
685 ); 685 );
686 } 686 }
@@ -713,18 +713,16 @@ impl Connect for Client {
713 } 713 }
714 if let Some(pb) = pb { 714 if let Some(pb) = pb {
715 pb.set_style(pb_after_style(true)); 715 pb.set_style(pb_after_style(true));
716 pb.set_prefix( 716 pb.set_prefix(format!(
717 dim.apply_to(format!( 717 "{} {}",
718 "{: <relay_column_width$} {}", 718 dim.apply_to(format!("{: <relay_column_width$}", &relay_url))
719 relay_url, 719 .for_stderr(),
720 if report.to_string().is_empty() { 720 if report.to_string().is_empty() {
721 "no new events".to_string() 721 "no new events".to_string()
722 } else { 722 } else {
723 format!("new events: {report}") 723 format!("new events: {report}")
724 }, 724 },
725 )) 725 ));
726 .to_string(),
727 );
728 pb.finish_with_message(""); 726 pb.finish_with_message("");
729 } 727 }
730 Ok(report) 728 Ok(report)
@@ -805,7 +803,7 @@ async fn get_events_of(
805 pb.set_message(format!( 803 pb.set_message(format!(
806 "{} {}", 804 "{} {}",
807 console::style("connection failed").for_stderr().red(), 805 console::style("connection failed").for_stderr().red(),
808 dim.apply_to(retry_msg) 806 dim.apply_to(retry_msg).for_stderr()
809 )); 807 ));
810 } 808 }
811 tokio::time::sleep(retry_delay).await; 809 tokio::time::sleep(retry_delay).await;
@@ -831,7 +829,7 @@ async fn get_events_of(
831 pb.set_message(format!( 829 pb.set_message(format!(
832 "{} {}", 830 "{} {}",
833 console::style("connection failed").for_stderr().red(), 831 console::style("connection failed").for_stderr().red(),
834 dim.apply_to(retry_msg) 832 dim.apply_to(retry_msg).for_stderr()
835 )); 833 ));
836 } 834 }
837 835
@@ -1113,6 +1111,7 @@ fn pb_style(current_timeout: Arc<AtomicU64>) -> Result<ProgressStyle> {
1113 w, 1111 w,
1114 "{}", 1112 "{}",
1115 dim.apply_to(format!("timeout in {:.1}s", timeout - elapsed)) 1113 dim.apply_to(format!("timeout in {:.1}s", timeout - elapsed))
1114 .for_stderr()
1116 ) 1115 )
1117 .unwrap(); 1116 .unwrap();
1118 } 1117 }