diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml deleted file mode 100644 index e9a430d..0000000 --- a/.github/workflows/gh-pages.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Documentation - -on: - push: - branches: - - master - -jobs: - build-deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - uses: actions-rs/cargo@v1 - with: - command: doc - args: --no-deps --all-features - - uses: peaceiris/actions-gh-pages@v3 - with: - deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} - publish_dir: ./target/doc diff --git a/Cargo.toml b/Cargo.toml index 500d439..04c02c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,3 @@ [workspace] members = ["cli-table", "cli-table-derive", "test-suite"] +resolver = "3" diff --git a/cli-table-derive/Cargo.toml b/cli-table-derive/Cargo.toml index 62007bb..f20043a 100644 --- a/cli-table-derive/Cargo.toml +++ b/cli-table-derive/Cargo.toml @@ -10,14 +10,18 @@ categories = ["command-line-interface"] keywords = ["table", "cli", "format"] readme = "README.md" include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-*"] -edition = "2018" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +default = [] +doc = [] + [dependencies] -proc-macro2 = "1.0.86" -syn = "1.0.109" -quote = "1.0.36" +proc-macro2 = "1.0.94" +syn = "2.0.100" +quote = "1.0.40" [lib] proc-macro = true diff --git a/cli-table-derive/src/context/fields.rs b/cli-table-derive/src/context/fields.rs index 5bb8643..4989082 100644 --- a/cli-table-derive/src/context/fields.rs +++ b/cli-table-derive/src/context/fields.rs @@ -1,8 +1,8 @@ use proc_macro2::{Span, TokenStream}; use quote::ToTokens; use syn::{ - spanned::Spanned, Data, DeriveInput, Error, Expr, Field as SynField, Fields as SynFields, - Ident, Index, Lit, LitBool, LitStr, Result, + Data, DeriveInput, Error, Expr, Field as SynField, Fields as SynFields, Ident, Index, Lit, + LitBool, LitStr, Result, spanned::Spanned, }; use crate::utils::get_attributes; diff --git a/cli-table-derive/src/lib.rs b/cli-table-derive/src/lib.rs index 44e7245..4d43c02 100644 --- a/cli-table-derive/src/lib.rs +++ b/cli-table-derive/src/lib.rs @@ -10,7 +10,7 @@ mod table; mod utils; use proc_macro::TokenStream; -use syn::{parse_macro_input, DeriveInput}; +use syn::{DeriveInput, parse_macro_input}; #[proc_macro_derive(Table, attributes(table))] /// Derive macro to implementing `cli_table` traits diff --git a/cli-table-derive/src/utils.rs b/cli-table-derive/src/utils.rs index 778c487..58a573d 100644 --- a/cli-table-derive/src/utils.rs +++ b/cli-table-derive/src/utils.rs @@ -1,49 +1,36 @@ -use syn::{spanned::Spanned, Attribute, Error, Lit, LitBool, Meta, NestedMeta, Path, Result}; +use syn::{Attribute, Error, Lit, LitBool, Path, Result, spanned::Spanned}; pub fn get_attributes(attrs: &[Attribute]) -> Result> { let mut attributes = Vec::new(); for attribute in attrs { - if !attribute.path.is_ident("table") { + if !attribute.path().is_ident("table") { continue; } - let meta = attribute.parse_meta()?; - - let meta_list = match meta { - Meta::List(meta_list) => Ok(meta_list), - bad => Err(Error::new_spanned( - bad, - "Attributes should be of type: #[table(key = \"value\", ..)]", - )), - }?; - - for nested_meta in meta_list.nested.into_iter() { - let meta = match nested_meta { - NestedMeta::Meta(meta) => Ok(meta), - bad => Err(Error::new_spanned( - bad, - "Attributes should be of type: #[table(key = \"value\", ..)]", - )), - }?; - - match meta { - Meta::Path(path) => { - let lit = LitBool { + if attribute + .parse_nested_meta(|meta| { + let path = meta.path.clone(); + let lit = meta + .value() + .ok() + .map(|v| v.parse()) + .transpose()? + .unwrap_or(Lit::from(LitBool { value: true, span: path.span(), - } - .into(); - attributes.push((path, lit)); - } - Meta::NameValue(meta_name_value) => { - attributes.push((meta_name_value.path, meta_name_value.lit)); - } - bad => return Err(Error::new_spanned( - bad, - "Attributes should be of type: #[table(key = \"value\", ..)] or #[table(bool)]", - )), - } + })); + + attributes.push((path, lit)); + + Ok(()) + }) + .is_err() + { + return Err(Error::new_spanned( + attribute, + "Attributes should be of type: #[table(key = \"value\", ..)] or #[table(bool)]", + )); } } diff --git a/cli-table/Cargo.toml b/cli-table/Cargo.toml index fd26cdf..7d739a1 100644 --- a/cli-table/Cargo.toml +++ b/cli-table/Cargo.toml @@ -10,7 +10,7 @@ categories = ["command-line-interface"] keywords = ["table", "cli", "format"] readme = "README.md" include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-*"] -edition = "2018" +edition = "2024" [lib] name = "cli_table" @@ -20,9 +20,9 @@ path = "src/lib.rs" [dependencies] cli-table-derive = { version = "0.4.6", path = "../cli-table-derive", optional = true } -csv = { version = "1.3.0", optional = true } +csv = { version = "1.3.1", optional = true } termcolor = "1.4.1" -unicode-width = "0.1.13" +unicode-width = "0.2.0" [features] default = ["csv", "derive"] diff --git a/cli-table/examples/csv.rs b/cli-table/examples/csv.rs index fb29833..ead2b1e 100644 --- a/cli-table/examples/csv.rs +++ b/cli-table/examples/csv.rs @@ -1,6 +1,6 @@ use std::{convert::TryFrom, io::Result}; -use cli_table::{print_stdout, TableStruct}; +use cli_table::{TableStruct, print_stdout}; use csv::ReaderBuilder; fn main() -> Result<()> { diff --git a/cli-table/examples/nested.rs b/cli-table/examples/nested.rs index 6f52461..b1803ee 100644 --- a/cli-table/examples/nested.rs +++ b/cli-table/examples/nested.rs @@ -1,6 +1,6 @@ use std::io::Result; -use cli_table::{format::Justify, Cell, Style, Table}; +use cli_table::{Cell, Style, Table, format::Justify}; fn main() -> Result<()> { let nested_table = vec![vec![20.cell()]].table(); diff --git a/cli-table/examples/simple.rs b/cli-table/examples/simple.rs index 9cd5858..e64453a 100644 --- a/cli-table/examples/simple.rs +++ b/cli-table/examples/simple.rs @@ -1,6 +1,6 @@ use std::io::Result; -use cli_table::{format::Justify, print_stdout, Cell, Style, Table}; +use cli_table::{Cell, Style, Table, format::Justify, print_stdout}; fn main() -> Result<()> { let table = vec![ diff --git a/cli-table/examples/struct.rs b/cli-table/examples/struct.rs index a4ecb3d..80f5618 100644 --- a/cli-table/examples/struct.rs +++ b/cli-table/examples/struct.rs @@ -1,8 +1,9 @@ use std::io::Result; use cli_table::{ + Color, Table, WithTitle, format::{Align, Justify}, - print_stdout, Color, Table, WithTitle, + print_stdout, }; #[derive(Debug, Table)] diff --git a/cli-table/examples/tuple_struct.rs b/cli-table/examples/tuple_struct.rs index 3c1c909..de2bdff 100644 --- a/cli-table/examples/tuple_struct.rs +++ b/cli-table/examples/tuple_struct.rs @@ -1,8 +1,9 @@ use std::io::Result; use cli_table::{ + Table, WithTitle, format::{HorizontalLine, Justify::Right, Separator}, - print_stdout, Table, WithTitle, + print_stdout, }; #[derive(Debug, Table)] diff --git a/cli-table/src/buffers.rs b/cli-table/src/buffers.rs index 0c4efb4..4bdfb41 100644 --- a/cli-table/src/buffers.rs +++ b/cli-table/src/buffers.rs @@ -51,7 +51,7 @@ impl<'a> Buffers<'a> { } } -impl<'a> Write for Buffers<'a> { +impl Write for Buffers<'_> { fn write(&mut self, buf: &[u8]) -> Result { if let Some(ref mut current_buffer) = self.current_buffer { current_buffer.write(buf) @@ -73,7 +73,7 @@ impl<'a> Write for Buffers<'a> { } } -impl<'a> WriteColor for Buffers<'a> { +impl WriteColor for Buffers<'_> { fn supports_color(&self) -> bool { match self.current_buffer { Some(ref buffer) => buffer.supports_color(), diff --git a/cli-table/src/utils.rs b/cli-table/src/utils.rs index 5deae24..a8b3cb8 100644 --- a/cli-table/src/utils.rs +++ b/cli-table/src/utils.rs @@ -104,9 +104,7 @@ pub(crate) fn print_horizontal_line( let mut widths = table_dimension.widths.iter().peekable(); while let Some(width) = widths.next() { - let s = std::iter::repeat(line.filler) - .take(width + 2) - .collect::(); + let s = std::iter::repeat_n(line.filler, width + 2).collect::(); print_str(buffers, &s, color_spec)?; match widths.peek() { diff --git a/test-suite/Cargo.toml b/test-suite/Cargo.toml index b93cc9c..3d1c588 100644 --- a/test-suite/Cargo.toml +++ b/test-suite/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "test-suite" version = "0.1.0" -authors = ["devashishdixit"] -edition = "2018" +authors = ["Devashish Dixit "] +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,5 +10,5 @@ edition = "2018" cli-table = { path = "../cli-table" } [dev-dependencies] -rustversion = "1.0.9" -trybuild = { version = "1.0.71", features = ["diff"] } +rustversion = "1.0.20" +trybuild = { version = "1.0.104", features = ["diff"] } diff --git a/test-suite/tests/ui/non-display-member.stderr b/test-suite/tests/ui/non-display-member.stderr index 368a546..37ec093 100644 --- a/test-suite/tests/ui/non-display-member.stderr +++ b/test-suite/tests/ui/non-display-member.stderr @@ -6,7 +6,7 @@ error[E0277]: the trait bound `&Vec: cli_table::Cell` is not satisfied 5 | struct Test { 6 | / #[table(title = "a")] 7 | | a: Vec, - | |_____^ the trait `std::fmt::Display` is not implemented for `&Vec`, which is required by `&Vec: cli_table::Cell` + | |______________^ the trait `std::fmt::Display` is not implemented for `Vec` | = help: the trait `cli_table::Cell` is implemented for `CellStruct` = note: required for `&Vec` to implement `std::fmt::Display`