feat: adds get_column_string

This commit is contained in:
itsscb 2024-08-12 12:33:51 +02:00
parent 32270d5e2e
commit eefb4c283c
2 changed files with 24 additions and 2 deletions

View File

@ -5,7 +5,7 @@ use anyhow::{anyhow, Result};
use crate::models::{DBState, Epic, Status, Story};
pub struct JiraDatabase {
database: Box<dyn Database>,
pub(crate) database: Box<dyn Database>,
}
impl JiraDatabase {

View File

@ -1,7 +1,29 @@
use ellipse::Ellipse;
pub fn get_column_string(text: &str, width: usize) -> String {
todo!() // use the truncate_ellipse function from the ellipse crate
match width {
0 => return String::new(),
1 => return ".".to_owned(),
2 => return "..".to_owned(),
3 => return "...".to_owned(),
_ => {}
}
let length = text.len();
if width == length {
return text.to_owned();
}
if width > length {
let diff = " ".repeat(width - length);
let mut out = text.to_owned();
out.push_str(&diff);
return out;
}
text.truncate_ellipse(width - 3).to_string()
}
#[cfg(test)]