cli: Show patch status in color in `patch show`

This commit is contained in:
Alexis Sellier 2023-04-06 14:37:13 +02:00
parent 7d1e3d489b
commit f999a62da2
No known key found for this signature in database
1 changed files with 7 additions and 1 deletions

View File

@ -45,6 +45,7 @@ pub fn run(
let Some(patch) = patches.get(patch_id)? else {
anyhow::bail!("Patch `{patch_id}` not found");
};
let state = patch.state();
let mut attrs = Table::<2, Paint<String>>::new(TableOptions {
spacing: 2,
@ -64,7 +65,12 @@ pub fn run(
]);
attrs.push([
term::format::tertiary("Status".to_owned()),
term::format::default(patch.state().to_string()),
match state {
patch::State::Open => term::format::positive(state.to_string()),
patch::State::Draft => term::format::dim(state.to_string()),
patch::State::Archived => term::format::yellow(state.to_string()),
patch::State::Merged => term::format::primary(state.to_string()),
},
]);
let description = patch.description().trim();