Skip to content

Commit

Permalink
deps: port from unmaintained term_size to terminal_size
Browse files Browse the repository at this point in the history
  • Loading branch information
decathorpe committed Nov 25, 2023
1 parent 84f89c3 commit f994923
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ secret-service = { version = "3", features = ["rt-tokio-crypto-rust"] }
serde = { version = "1.0.134", features = ["derive"] }
serde_json = "1.0.78"
tempfile = "3.3.0"
term_size = "0.3.2"
terminal_size = "0.3"
textwrap = "0.16"
tokio = { version = "1.14", features = ["fs", "macros", "process", "rt-multi-thread"] }
toml = "0.8"
Expand Down
20 changes: 12 additions & 8 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::io::{stdout, Write};

use bodhi::{Comment, Update};
use chrono::{DateTime, Duration, Utc};
use terminal_size::{terminal_size, Width};

use crate::parse::parse_nvr;

Expand All @@ -12,8 +13,8 @@ use crate::parse::parse_nvr;
///
/// It's necessary to print a newline character after the progress bar reaches 100%.
pub fn progress_bar(prefix: &str, p: u32, ps: u32) {
let columns: u32 = match term_size::dimensions() {
Some((w, _)) => w as u32,
let columns: u32 = match terminal_size() {
Some((Width(width), _)) => width as u32,
None => return,
};

Expand Down Expand Up @@ -108,8 +109,9 @@ pub fn print_update(
println!();

// block for pretty-printing width-constrained strings
match term_size::dimensions() {
Some((w, _)) => {
match terminal_size() {
Some((Width(width), _)) => {
let w = width as usize;
// construct a nice header banner for the update
let boxie = "#".repeat(w);
let header = if update.alias.len() > (w - 6) {
Expand Down Expand Up @@ -186,8 +188,9 @@ pub fn print_update(

if let Some(title) = title {
// make sure bug title doesn't contain words that are split across lines
match term_size::dimensions() {
Some((w, _)) => {
match terminal_size() {
Some((Width(width), _)) => {
let w = width as usize;
println!("{}", textwrap::indent(&textwrap::fill(title.trim(), w - 3), " "));
},
None => {
Expand Down Expand Up @@ -247,8 +250,9 @@ pub fn print_update(
println!("- {} ({}): {}", &comment.user.name, &comment.timestamp, &comment.karma);

let trimmed = comment.text.trim();
match term_size::dimensions() {
Some((w, _)) => {
match terminal_size() {
Some((Width(width), _)) => {
let w = width as usize;
if !trimmed.is_empty() {
println!("{}", textwrap::indent(&textwrap::fill(trimmed, w - 3), " "));
}
Expand Down

0 comments on commit f994923

Please sign in to comment.