diff --git a/Cargo.lock b/Cargo.lock index 73196abb6c0..feac5975ea0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -297,6 +297,12 @@ dependencies = [ "utf8-width", ] +[[package]] +name = "bytecount" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" + [[package]] name = "bytes" version = "1.2.1" @@ -954,6 +960,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "form_urlencoded" version = "1.1.0" @@ -1837,6 +1849,7 @@ dependencies = [ "gitoxide-core", "owo-colors", "prodash", + "tabled", ] [[package]] @@ -2387,6 +2400,17 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +[[package]] +name = "papergrid" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453cf71f2a37af495a1a124bf30d4d7469cfbea58e9f2479be9d222396a518a2" +dependencies = [ + "bytecount", + "fnv", + "unicode-width", +] + [[package]] name = "parking" version = "2.0.0" @@ -2933,6 +2957,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tabled" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5b2f8c37d26d87d2252187b0a45ea3cbf42baca10377c7e7eaaa2800fa9bf97" +dependencies = [ + "papergrid", + "unicode-width", +] + [[package]] name = "tar" version = "0.4.38" diff --git a/Cargo.toml b/Cargo.toml index 96ce65e2e7e..e00a3cae59e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,8 +92,9 @@ env_logger = { version = "0.9.0", default-features = false } crosstermion = { version = "0.10.1", optional = true, default-features = false } futures-lite = { version = "1.12.0", optional = true, default-features = false, features = ["std"] } -# for show-progress +# for progress owo-colors = "3.5.0" +tabled = { version = "0.8.0", default-features = false } document-features = { version = "0.2.0", optional = true } diff --git a/src/plumbing/progress.rs b/src/plumbing/progress.rs index ebf4fd654e5..a06ea1e63fc 100644 --- a/src/plumbing/progress.rs +++ b/src/plumbing/progress.rs @@ -1,6 +1,6 @@ -use crosstermion::crossterm::style::Stylize; use owo_colors::OwoColorize; use std::fmt::{Display, Formatter}; +use tabled::{Style, TableIteratorExt, Tabled}; #[derive(Clone)] enum Usage { @@ -52,6 +52,18 @@ struct Record { usage: Usage, } +impl Tabled for Record { + const LENGTH: usize = 3; + + fn fields(&self) -> Vec { + vec![self.usage.icon().into(), self.config.into(), self.usage.to_string()] + } + + fn headers() -> Vec { + vec![] + } +} + static GIT_CONFIG: &[Record] = &[ Record { config: "fetch.output", @@ -80,8 +92,7 @@ pub fn show_progress() -> anyhow::Result<()> { v }; - for Record { config, usage } in sorted { - println!("{} {}: {usage}", usage.icon(), config.bold(),); - } + println!("{}", sorted.table().with(Style::blank())); + println!("\nTotal records: {}", GIT_CONFIG.len()); Ok(()) }