diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2024-06-16 17:07:21 +0200 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2024-06-16 17:07:21 +0200 |
commit | d82a5f6e1bc878b0e6a695f88eb69404ca6d571d (patch) | |
tree | 321d55c3ff700187cba1938da119825260780193 /src/parseopts.rs | |
parent | 93883014f75ee9005a69d57ccb2d653015b6c216 (diff) | |
download | textgraph-d82a5f6e1bc878b0e6a695f88eb69404ca6d571d.tar.gz textgraph-d82a5f6e1bc878b0e6a695f88eb69404ca6d571d.zip |
Make platform dependent code possible to disable by disabling libc and ansi features
Diffstat (limited to 'src/parseopts.rs')
-rw-r--r-- | src/parseopts.rs | 14 |
1 files changed, 13 insertions, 1 deletions
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, |