Showing the changes to src (1 of 3 files). Show all
Unified · Split
| @@ -5,9 +5,6 @@ use std::{ · 4 unmodified lines | |||
| 5 | 5 | ||
| 6 | use crosstermion::crossterm::style::Stylize; | 6 | use crosstermion::crossterm::style::Stylize; |
| 7 | use owo_colors::OwoColorize; | 7 | use owo_colors::OwoColorize; |
| 8 | use tabled::settings::peaker::PriorityMax; | ||
| 9 | use tabled::settings::{Extract, Style, Width}; | ||
| 10 | use tabled::Tabled; | ||
| 11 | 8 | ||
| 12 | #[derive(Clone)] | 9 | #[derive(Clone)] |
| 13 | enum Usage { | 10 | enum Usage { |
| @@ -73,33 +70,35 @@ struct Record { · 59 unmodified lines | |||
| 73 | usage: Usage, | 70 | usage: Usage, |
| 74 | } | 71 | } |
| 75 | 72 | ||
| 76 | impl Tabled for Record { | 73 | // TODO implement this without table, how hard is it? |
| 77 | const LENGTH: usize = 3; | ||
| 78 | 74 | ||
| 79 | fn fields(&self) -> Vec<Cow<'_, str>> { | 75 | // impl Tabled for Record { |
| 80 | let mut tokens = self.config.split('.'); | 76 | // const LENGTH: usize = 3; |
| 81 | let mut buf = vec![{ | ||
| 82 | let name = tokens.next().expect("present"); | ||
| 83 | if name == "gitoxide" { | ||
| 84 | name.bold().green() | ||
| 85 | } else { | ||
| 86 | name.bold() | ||
| 87 | } | ||
| 88 | .to_string() | ||
| 89 | }]; | ||
| 90 | buf.extend(tokens.map(ToOwned::to_owned)); | ||
| 91 | 77 | ||
| 92 | vec![ | 78 | // fn fields(&self) -> Vec<Cow<'_, str>> { |
| 93 | Cow::Borrowed(self.usage.icon()), | 79 | // let mut tokens = self.config.split('.'); |
| 94 | buf.join(".").into(), | 80 | // let mut buf = vec![{ |
| 95 | self.usage.to_string().into(), | 81 | // let name = tokens.next().expect("present"); |
| 96 | ] | 82 | // if name == "gitoxide" { |
| 97 | } | 83 | // name.bold().green() |
| 84 | // } else { | ||
| 85 | // name.bold() | ||
| 86 | // } | ||
| 87 | // .to_string() | ||
| 88 | // }]; | ||
| 89 | // buf.extend(tokens.map(ToOwned::to_owned)); | ||
| 98 | 90 | ||
| 99 | fn headers() -> Vec<Cow<'static, str>> { | 91 | // vec![ |
| 100 | vec!["icon".into(), "key".into(), "info".into()] | 92 | // Cow::Borrowed(self.usage.icon()), |
| 101 | } | 93 | // buf.join(".").into(), |
| 102 | } | 94 | // self.usage.to_string().into(), |
| 95 | // ] | ||
| 96 | // } | ||
| 97 | |||
| 98 | // fn headers() -> Vec<Cow<'static, str>> { | ||
| 99 | // vec!["icon".into(), "key".into(), "info".into()] | ||
| 100 | // } | ||
| 101 | // } | ||
| 103 | 102 | ||
| 104 | static GIT_CONFIG: &[Record] = &[ | 103 | static GIT_CONFIG: &[Record] = &[ |
| 105 | Record { | 104 | Record { |
| @@ -575,16 +574,18 @@ pub fn show_progress() -> anyhow::Result<()> { · 469 unmodified lines | |||
| 575 | .count() | 574 | .count() |
| 576 | )?; | 575 | )?; |
| 577 | 576 | ||
| 578 | let mut table = tabled::Table::new(sorted); | 577 | // TODO implement this without table, how hard is it? |
| 579 | let table = table.with(Style::blank()).with(Extract::rows(1..)); | 578 | |
| 580 | println!( | 579 | // let mut table = tabled::Table::new(sorted); |
| 581 | "{}", | 580 | // let table = table.with(Style::blank()).with(Extract::rows(1..)); |
| 582 | if let Some((terminal_size::Width(w), _)) = terminal_size::terminal_size() { | 581 | // println!( |
| 583 | table.with(Width::wrap(w as usize).keep_words().priority::<PriorityMax>()) | 582 | // "{}", |
| 584 | } else { | 583 | // if let Some((terminal_size::Width(w), _)) = terminal_size::terminal_size() { |
| 585 | table | 584 | // table.with(Width::wrap(w as usize).keep_words().priority::<PriorityMax>()) |
| 586 | } | 585 | // } else { |
| 587 | ); | 586 | // table |
| 587 | // } | ||
| 588 | // ); | ||
| 588 | println!("{buf}"); | 589 | println!("{buf}"); |
| 589 | Ok(()) | 590 | Ok(()) |
| 590 | } | 591 | } |