From d82a5f6e1bc878b0e6a695f88eb69404ca6d571d Mon Sep 17 00:00:00 2001 From: jakobst1n Date: Sun, 16 Jun 2024 17:07:21 +0200 Subject: Make platform dependent code possible to disable by disabling libc and ansi features --- src/parseopts.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/parseopts.rs') diff --git a/src/parseopts.rs b/src/parseopts.rs index 60f811e..fb04c0d 100644 --- a/src/parseopts.rs +++ b/src/parseopts.rs @@ -40,20 +40,32 @@ impl OptsBuilder { pub fn build(self) -> Opts { Opts { width: self.width.unwrap_or_else(|| { + #[cfg(feature = "libc")] if let Ok((width, _)) = crate::term::get_terminal_size() { width as usize } else { - println!("Could not determine TTY columns, specify with -r"); + println!("Could not determine TTY columns, specify with -w"); + std::process::exit(1); + } + #[cfg(not(feature = "libc"))] + { + println!("Not compiled with libc, cannot detect columns, specify with -w"); std::process::exit(1); } }), height: self.height.unwrap_or_else(|| { + #[cfg(feature = "libc")] if let Ok((_, height)) = crate::term::get_terminal_size() { height as usize - 1 } else { println!("Could not determine TTY rows, specify with -h"); std::process::exit(1); } + #[cfg(not(feature = "libc"))] + { + println!("Not compiled with libc, cannot detect rows, specify with -h"); + std::process::exit(1); + } }), graph_type: self.graph_type, silent: self.silent, -- cgit v1.2.3