cli: Use term::Table to print list of issues
Signed-off-by: Slack Coder <slackcoder@server.ky>
This commit is contained in:
parent
946d6ac675
commit
6b67e0571e
|
|
@ -233,6 +233,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
}
|
||||
}
|
||||
Operation::List => {
|
||||
let mut t = term::Table::new(term::table::TableOptions::default());
|
||||
for result in issues.all()? {
|
||||
let (id, issue, _) = result?;
|
||||
|
||||
|
|
@ -241,12 +242,13 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
.map(|p| p.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
if assigned.is_empty() {
|
||||
println!("{} \"{}\"", id, issue.title().escape_default());
|
||||
} else {
|
||||
println!("{} {:?} {}", id, issue.title().escape_default(), &assigned,);
|
||||
}
|
||||
t.push([
|
||||
id.to_string(),
|
||||
format!("{:?}", issue.title()),
|
||||
assigned.to_string(),
|
||||
]);
|
||||
}
|
||||
t.render();
|
||||
}
|
||||
Operation::Delete { id } => {
|
||||
issues.remove(&id)?;
|
||||
|
|
|
|||
|
|
@ -59,10 +59,12 @@ impl<const W: usize> Table<W> {
|
|||
.ok();
|
||||
}
|
||||
}
|
||||
|
||||
let output = output.trim_end();
|
||||
println!(
|
||||
"{}",
|
||||
if let Some(width) = width {
|
||||
console::truncate_str(&output, width - 1, "…")
|
||||
console::truncate_str(output, width - 1, "…")
|
||||
} else {
|
||||
output.into()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue