get the actual terminal width
This commit is contained in:
parent
e59211f1f9
commit
5d3b50d552
|
@ -415,6 +415,16 @@ dependencies = [
|
|||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
|
@ -467,6 +477,7 @@ dependencies = [
|
|||
"rusqlite",
|
||||
"serde",
|
||||
"serde_yaml",
|
||||
"terminal_size",
|
||||
"textwrap 0.14.2",
|
||||
"thiserror",
|
||||
"toml",
|
||||
|
|
|
@ -17,6 +17,7 @@ serde_yaml = "0.8"
|
|||
toml = "0.5"
|
||||
itertools = "0.10"
|
||||
textwrap = "0.14"
|
||||
terminal_size = "0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "0.7.2"
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::str::FromStr;
|
|||
|
||||
use clap::ArgMatches;
|
||||
use chrono::{DateTime, Utc, Local, TimeZone};
|
||||
use terminal_size::{Width, terminal_size};
|
||||
|
||||
use crate::error;
|
||||
use crate::database::Database;
|
||||
|
@ -12,6 +13,14 @@ use crate::config::Config;
|
|||
|
||||
use super::Command;
|
||||
|
||||
fn term_width() -> usize {
|
||||
if let Some((Width(w), _)) = terminal_size() {
|
||||
w as usize
|
||||
} else {
|
||||
80
|
||||
}
|
||||
}
|
||||
|
||||
enum Sheet {
|
||||
All,
|
||||
Full,
|
||||
|
@ -76,6 +85,13 @@ impl<'a> Command<'a> for DisplayCommand {
|
|||
}
|
||||
};
|
||||
|
||||
args.format.print_formatted(sheets_to_display, out, Utc::now(), Local.offset_from_utc_datetime(&Utc::now().naive_utc()), args.ids, 100)
|
||||
args.format.print_formatted(
|
||||
sheets_to_display,
|
||||
out,
|
||||
Utc::now(),
|
||||
Local.offset_from_utc_datetime(&Utc::now().naive_utc()),
|
||||
args.ids,
|
||||
term_width(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue