diff --git a/Cargo.lock b/Cargo.lock index b8b5692..12d1955 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2332,15 +2332,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" -[[package]] -name = "mea" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31fc7d159de0085ab6dd7ff145a9819442cfd3d098f783263120503c3f3e58b0" -dependencies = [ - "slab", -] - [[package]] name = "memchr" version = "2.8.3" @@ -2901,7 +2892,6 @@ dependencies = [ "jiff", "log", "logforth", - "mea", "memchr", "nu-ansi-term", "reedline", diff --git a/scopeql/Cargo.toml b/scopeql/Cargo.toml index e20d2df..e4db6c1 100644 --- a/scopeql/Cargo.toml +++ b/scopeql/Cargo.toml @@ -46,7 +46,6 @@ indicatif = { version = "0.18.6" } jiff = { version = "0.2.35", features = ["serde"] } log = { version = "0.4.33" } logforth = { version = "0.30.1", features = ["starter-log"] } -mea = { version = "0.6.5" } memchr = { version = "2.8.3" } nu-ansi-term = { version = "0.50.3" } reedline = { version = "0.49.0" } diff --git a/scopeql/src/repl/entrypoint.rs b/scopeql/src/repl/entrypoint.rs index 27edc77..f6ec328 100644 --- a/scopeql/src/repl/entrypoint.rs +++ b/scopeql/src/repl/entrypoint.rs @@ -20,7 +20,6 @@ use clap::Parser; use exn::Result; use indicatif::ProgressBar; use indicatif::ProgressStyle; -use mea::latch::Latch; use nu_ansi_term::Color; use nu_ansi_term::Style; use reedline::DefaultHinter; @@ -249,9 +248,20 @@ pub fn entrypoint(config: &Config) { } loop { - let input = line_editor - .read_line(&repl.prompt) - .expect("failed to read next line"); + let input = match line_editor.read_line(&repl.prompt) { + Ok(input) => input, + Err(err) => { + if matches!(err.kind(), std::io::ErrorKind::Other) { + let err = err.to_string(); + if err.contains("cursor position could not be read within a normal duration") { + continue; + } + } + eprintln!("error: failed to read input: {err}"); + return; + } + }; + let input = match input { Signal::Success(input) if input == CTRL_C_PROMPT_COMMAND || input == CTRL_D_PROMPT_COMMAND => @@ -388,18 +398,7 @@ pub fn entrypoint(config: &Config) { let pb_style = "{spinner:.green} [{elapsed_precise}] {msg:.green.bold.bright} [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({bytes_per_sec})"; let pb = ProgressBar::no_length() .with_style(ProgressStyle::with_template(pb_style).unwrap()); - let stop_pb = Arc::new(Latch::new(1)); - - global::rt().spawn({ - let pb = pb.clone(); - let stop_pb = stop_pb.clone(); - async move { - while stop_pb.try_wait().is_err() { - tokio::time::sleep(Duration::from_millis(42)).await; - pb.tick(); - } - } - }); + pb.enable_steady_tick(Duration::from_millis(42)); let client = &repl.client; let output_format = repl.output_format; @@ -432,7 +431,7 @@ pub fn entrypoint(config: &Config) { } }); - stop_pb.count_down(); + pb.disable_steady_tick(); pb.finish_and_clear(); match output {