chj_rustbin/
get_terminal_width.rs

1//! Hack to get terminal width to allow making older Clap versions
2//! auto-adapt to the current width.
3
4pub fn get_terminal_width() -> usize {
5    let default = 120;
6    if let Some((terminal_size::Width(width), _height)) =
7        terminal_size::terminal_size()
8    {
9        usize::from(width).checked_sub(4).unwrap_or(default)
10    } else {
11        default
12    }
13}