From 465e4c40abee7e229426f74e4ecfa83f9d1ff658 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 12 Aug 2025 16:18:53 -0300 Subject: [PATCH] refactor: replace custom isatty implementation with is-terminal crate Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) --- src/modes/get.rs | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/modes/get.rs b/src/modes/get.rs index 0b89b72..8753bbc 100644 --- a/src/modes/get.rs +++ b/src/modes/get.rs @@ -6,6 +6,7 @@ use crate::common::is_binary::is_binary; use clap::Command; use std::path::PathBuf; use std::str::FromStr; +use is_terminal::IsTerminal; pub fn mode_get( cmd: &mut Command, @@ -46,7 +47,7 @@ pub fn mode_get( item_path.push(item_id.to_string()); // Determine if we should detect binary data - let mut detect_binary = !args.options.force && is_stdout_tty(); + let mut detect_binary = !args.options.force && std::io::stdout().is_terminal(); // If we're detecting binary and there's binary metadata, check it if detect_binary { @@ -94,21 +95,3 @@ pub fn mode_get( Err(anyhow!("Unable to find matching item in database")) } } - -fn is_stdout_tty() -> bool { - #[cfg(unix)] - unsafe { - libc::isatty(libc::STDOUT_FILENO) != 0 - } - - #[cfg(windows)] - unsafe { - let stdout_handle = winapi::um::processenv::GetStdHandle(winapi::um::winbase::STD_OUTPUT_HANDLE); - let mut console_mode: winapi::shared::minwindef::DWORD = 0; - winapi::um::consoleapi::GetConsoleMode(stdout_handle, &mut console_mode) != 0 - } - - // Fallback for non-unix platforms or if we can't determine - #[cfg(not(any(unix, windows)))] - false -}