colored table

This commit is contained in:
Kasper Juul Hermansen 2023-01-10 22:33:11 +01:00
parent 35b50d802a
commit b7a865b48e
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
2 changed files with 16 additions and 11 deletions

View File

@ -19,13 +19,13 @@ impl Review {
Self { backend } Self { backend }
} }
// Workflow /// Workflow
// 1. Fetch list of repos /// 1. Fetch list of repos
// 2. Present menu /// 2. Present menu
// 3. Choose begin quick review /// 3. Choose begin quick review
// 4. Present pr and use delta to view changes /// 4. Present pr and use delta to view changes
// 5. Approve, open, skip or quit /// 5. Approve, open, skip or quit
// 6. Repeat from 4 /// 6. Repeat from 4
fn run(&self, review_requested: Option<String>) -> eyre::Result<()> { fn run(&self, review_requested: Option<String>) -> eyre::Result<()> {
let prs = self.backend.get_prs(review_requested)?; let prs = self.backend.get_prs(review_requested)?;
@ -42,13 +42,17 @@ impl Review {
.load_preset(UTF8_HORIZONTAL_ONLY) .load_preset(UTF8_HORIZONTAL_ONLY)
.set_content_arrangement(comfy_table::ContentArrangement::Dynamic) .set_content_arrangement(comfy_table::ContentArrangement::Dynamic)
.set_header(vec![ .set_header(vec![
Cell::new("repo"), Cell::new("repo").add_attribute(comfy_table::Attribute::Bold),
Cell::new("title"), Cell::new("title").add_attribute(comfy_table::Attribute::Bold),
Cell::new("number"), Cell::new("number").add_attribute(comfy_table::Attribute::Bold),
]) ])
.add_rows(prs.iter().map(|pr| { .add_rows(prs.iter().map(|pr| {
let pr = pr.clone(); let pr = pr.clone();
vec![pr.repository.name, pr.title, pr.number.to_string()] vec![
Cell::new(pr.repository.name).fg(comfy_table::Color::Green),
Cell::new(pr.title),
Cell::new(pr.number.to_string()),
]
})); }));
table.to_string() table.to_string()

View File

@ -42,6 +42,7 @@ impl ReviewBackend for DefaultReviewBackend {
} }
fn present_prs(&self, table: String) -> eyre::Result<()> { fn present_prs(&self, table: String) -> eyre::Result<()> {
println!("{table}");
Ok(()) Ok(())
} }
} }