Skip to content

Commit

Permalink
remove tabled
Browse files Browse the repository at this point in the history
  • Loading branch information
benmkw committed Feb 16, 2024
1 parent 5fc379d commit fcd585b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 171 deletions.
134 changes: 1 addition & 133 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ tracing = { version = "0.1.37", optional = true }
owo-colors = "4.0.0"

# for config-tree
tabled = { version = "0.15.0", features = ["ansi"] }
terminal_size = "0.3.0"

# Avoid pre-compiled binaries, see https://github.com/serde-rs/serde/issues/2538 and https://github.com/serde-rs/serde/pull/2590
Expand Down
75 changes: 38 additions & 37 deletions src/plumbing/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ use std::{

use crosstermion::crossterm::style::Stylize;
use owo_colors::OwoColorize;
use tabled::settings::peaker::PriorityMax;
use tabled::settings::{Extract, Style, Width};
use tabled::Tabled;

#[derive(Clone)]
enum Usage {
Expand Down Expand Up @@ -73,33 +70,35 @@ struct Record {
usage: Usage,
}

impl Tabled for Record {
const LENGTH: usize = 3;
// TODO implement this without table, how hard is it?

fn fields(&self) -> Vec<Cow<'_, str>> {
let mut tokens = self.config.split('.');
let mut buf = vec![{
let name = tokens.next().expect("present");
if name == "gitoxide" {
name.bold().green()
} else {
name.bold()
}
.to_string()
}];
buf.extend(tokens.map(ToOwned::to_owned));
// impl Tabled for Record {
// const LENGTH: usize = 3;

vec![
Cow::Borrowed(self.usage.icon()),
buf.join(".").into(),
self.usage.to_string().into(),
]
}
// fn fields(&self) -> Vec<Cow<'_, str>> {
// let mut tokens = self.config.split('.');
// let mut buf = vec![{
// let name = tokens.next().expect("present");
// if name == "gitoxide" {
// name.bold().green()
// } else {
// name.bold()
// }
// .to_string()
// }];
// buf.extend(tokens.map(ToOwned::to_owned));

fn headers() -> Vec<Cow<'static, str>> {
vec!["icon".into(), "key".into(), "info".into()]
}
}
// vec![
// Cow::Borrowed(self.usage.icon()),
// buf.join(".").into(),
// self.usage.to_string().into(),
// ]
// }

// fn headers() -> Vec<Cow<'static, str>> {
// vec!["icon".into(), "key".into(), "info".into()]
// }
// }

static GIT_CONFIG: &[Record] = &[
Record {
Expand Down Expand Up @@ -575,16 +574,18 @@ pub fn show_progress() -> anyhow::Result<()> {
.count()
)?;

let mut table = tabled::Table::new(sorted);
let table = table.with(Style::blank()).with(Extract::rows(1..));
println!(
"{}",
if let Some((terminal_size::Width(w), _)) = terminal_size::terminal_size() {
table.with(Width::wrap(w as usize).keep_words().priority::<PriorityMax>())
} else {
table
}
);
// TODO implement this without table, how hard is it?

// let mut table = tabled::Table::new(sorted);
// let table = table.with(Style::blank()).with(Extract::rows(1..));
// println!(
// "{}",
// if let Some((terminal_size::Width(w), _)) = terminal_size::terminal_size() {
// table.with(Width::wrap(w as usize).keep_words().priority::<PriorityMax>())
// } else {
// table
// }
// );
println!("{buf}");
Ok(())
}

0 comments on commit fcd585b

Please sign in to comment.