|
3 | 3 | use std::path::PathBuf;
|
4 | 4 |
|
5 | 5 | use crate::{
|
6 |
| - commands::{get_repository, init::init, open_repository}, |
7 |
| - helpers::bytes_size_to_string, |
| 6 | + commands::{get_repository, init::init, open_repository, snapshots::fill_table}, |
| 7 | + helpers::{bold_cell, bytes_size_to_string, table}, |
8 | 8 | status_err, Application, RUSTIC_APP,
|
9 | 9 | };
|
10 | 10 |
|
11 | 11 | use abscissa_core::{Command, Runnable, Shutdown};
|
12 | 12 | use anyhow::{bail, Context, Result};
|
13 | 13 | use clap::ValueHint;
|
| 14 | +use comfy_table::Cell; |
14 | 15 | use log::{debug, info, warn};
|
15 | 16 | use merge::Merge;
|
16 | 17 | use serde::{Deserialize, Serialize};
|
@@ -63,9 +64,14 @@ pub struct BackupCmd {
|
63 | 64 | #[merge(strategy = merge::bool::overwrite_false)]
|
64 | 65 | json: bool,
|
65 | 66 |
|
66 |
| - /// Don't show any output |
| 67 | + /// Show detailed information about generated snapshot |
67 | 68 | #[clap(long, conflicts_with = "json")]
|
68 | 69 | #[merge(strategy = merge::bool::overwrite_false)]
|
| 70 | + long: bool, |
| 71 | + |
| 72 | + /// Don't show any output |
| 73 | + #[clap(long, conflicts_with_all = ["json", "long"])] |
| 74 | + #[merge(strategy = merge::bool::overwrite_false)] |
69 | 75 | quiet: bool,
|
70 | 76 |
|
71 | 77 | /// Initialize repository, if it doesn't exist yet
|
@@ -238,6 +244,15 @@ impl BackupCmd {
|
238 | 244 | if opts.json {
|
239 | 245 | let mut stdout = std::io::stdout();
|
240 | 246 | serde_json::to_writer_pretty(&mut stdout, &snap)?;
|
| 247 | + } else if opts.long { |
| 248 | + let mut table = table(); |
| 249 | + |
| 250 | + let add_entry = |title: &str, value: String| { |
| 251 | + _ = table.add_row([bold_cell(title), Cell::new(value)]); |
| 252 | + }; |
| 253 | + fill_table(&snap, add_entry); |
| 254 | + |
| 255 | + println!("{table}"); |
241 | 256 | } else if !opts.quiet {
|
242 | 257 | let summary = snap.summary.unwrap();
|
243 | 258 | println!(
|
|
0 commit comments