From 53bf604072104e1e84148ea27aedfb31e94b77de Mon Sep 17 00:00:00 2001 From: AmrDeveloper Date: Mon, 4 Nov 2024 19:19:18 +0100 Subject: [PATCH] Replace `atty` with std is terminal --- Cargo.lock | 21 --------------------- Cargo.toml | 1 - src/main.rs | 7 ++++--- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f1c2969..80082bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,17 +26,6 @@ dependencies = [ "libc", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.2.0" @@ -101,7 +90,6 @@ dependencies = [ name = "clangql" version = "0.7.0" dependencies = [ - "atty", "clang-sys", "gitql-ast", "gitql-cli", @@ -263,15 +251,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "iana-time-zone" version = "0.1.60" diff --git a/Cargo.toml b/Cargo.toml index 005dc4d..00017bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,5 +19,4 @@ gitql-cli = "0.28.0" gitql-ast = "0.25.0" gitql-parser = "0.27.0" gitql-engine = "0.28.0" -atty = "0.2.14" clang-sys = "1.8.1" diff --git a/src/main.rs b/src/main.rs index a14b12e..aa0a27d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,9 @@ +use std::io::IsTerminal; use std::path::Path; use crate::engine::EvaluationResult::SelectedGroups; use arguments::Arguments; use arguments::Command; -use atty::Stream; use data_provider::ClangAstDataProvider; use gitql_cli::arguments::OutputFormat; use gitql_cli::diagnostic_reporter; @@ -101,13 +101,14 @@ fn launch_clangql_repl(arguments: Arguments) { let mut input = String::new(); loop { + let stdio = std::io::stdin(); // Render Prompt only if input is received from terminal - if atty::is(Stream::Stdin) { + if stdio.is_terminal() { print!("clangql > "); } std::io::Write::flush(&mut std::io::stdout()).expect("flush failed!"); - match std::io::stdin().read_line(&mut input) { + match stdio.read_line(&mut input) { Ok(buffer_length) => { if buffer_length == 0 { break;