mirror of
https://github.com/qwjyh/xdbm
synced 2024-12-05 04:51:04 +09:00
add: style to cmd_status
This commit is contained in:
parent
c4aa76d125
commit
af1b56eee2
1 changed files with 11 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
use anyhow::{Context, Result};
|
||||
use chrono::Local;
|
||||
use console::Style;
|
||||
use std::{
|
||||
env,
|
||||
path::{self, Path, PathBuf},
|
||||
|
@ -96,14 +97,20 @@ pub(crate) fn cmd_status(
|
|||
for (backup_device, covering_backups) in covering_backup {
|
||||
println!("Device: {}", backup_device.name());
|
||||
for (backup, path_from_backup) in covering_backups {
|
||||
let last_backup = match backup.last_backup() {
|
||||
Some(log) => util::format_summarized_duration(Local::now() - log.datetime),
|
||||
None => "---".to_string(),
|
||||
let (last_backup, style) = match backup.last_backup() {
|
||||
Some(log) => {
|
||||
let timediff = Local::now() - log.datetime;
|
||||
(
|
||||
util::format_summarized_duration(timediff),
|
||||
util::duration_style(timediff),
|
||||
)
|
||||
}
|
||||
None => ("---".to_string(), Style::new().red()),
|
||||
};
|
||||
println!(
|
||||
" {:<name_len$} {} {}",
|
||||
console::style(backup.name()).bold(),
|
||||
last_backup,
|
||||
style.apply_to(last_backup),
|
||||
path_from_backup.display(),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue