diff --git a/.github/workflows/msrv.yaml b/.github/workflows/msrv.yaml deleted file mode 100644 index d811c71..0000000 --- a/.github/workflows/msrv.yaml +++ /dev/null @@ -1,53 +0,0 @@ -name: MSRV - -on: - push: - branches: [] - pull_request: - branches: [] - -defaults: - run: - shell: bash - -env: - CARGO_TERM_COLOR: always - -jobs: - all: - name: All - - strategy: - matrix: - target: - - x86_64-unknown-linux-gnu - - x86_64-apple-darwin - include: - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - - target: x86_64-apple-darwin - os: macos-latest - - runs-on: ${{matrix.os}} - - env: - RUSTFLAGS: "-D warnings" - - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - uses: taiki-e/install-action@v2 - with: - tool: cargo-msrv - - - name: Info - run: | - rustup --version - cargo --version - cargo clippy --version - - - name: MSRV - run: | - cargo msrv verify diff --git a/CREDITS.md b/CREDITS.md index bfaf09a..9a1ea70 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -1,18 +1,18 @@ # Project Dependencies Package: yesvgmap - Version: 0.5.2 - Generated: 2024-02-08 20:47:02 UTC + Version: 0.5.3 + Generated: 2024-02-16 19:23:04 UTC | Package | Version | Author(s) | License | | ---- | ---- | ---- | ---- | -| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.7 | [Tom Kaitchuck](mailto:tom.kaitchuck@gmail.com) | Apache-2.0 or MIT | -| [argyle](https://github.com/Blobfolio/argyle) | 0.7.1 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | +| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.8 | [Tom Kaitchuck](mailto:tom.kaitchuck@gmail.com) | Apache-2.0 or MIT | +| [argyle](https://github.com/Blobfolio/argyle) | 0.7.2 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | | [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:alex@alexcrichton.com) | Apache-2.0 or MIT | | [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | -| [dowser](https://github.com/Blobfolio/dowser) | 0.8.2 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | +| [dowser](https://github.com/Blobfolio/dowser) | 0.9.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | | [fastrand](https://github.com/smol-rs/fastrand) | 2.0.1 | [Stjepan Glavina](mailto:stjepang@gmail.com) | Apache-2.0 or MIT | -| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.12.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | -| [svg](https://github.com/bodoni/svg) | 0.15.0 | [Adam Bryant](mailto:adam.w.bryant@outlook.com), [Felix Schütt](mailto:felix.schuett@maps4print.com), [GeoffreyY](mailto:yeungchingho123@gmail.com), [Gijs Burghoorn](mailto:g.burghoorn@gmail.com), [Ivan Ukhov](mailto:ivan.ukhov@gmail.com), [Jack Greenbaum](mailto:j.greenbaum@computer.org), [Mike Wilkerson](mailto:mwilkerson@gmail.com), [Nathan Hüsken](mailto:nathan@wintercloud.de), [Nathaniel Cook](mailto:nvcook42@gmail.com), [Nick Angelou](mailto:angelou.nick@gmail.com), [Nicolas Silva](mailto:nical@fastmail.com), [Nor Khasyatillah](mailto:mazznoer@ymail.com), [OCTronics](mailto:octronics@riseup.net), [Patrick Chieppe](mailto:patrick.chieppe@hotmail.com), [Will Nelson](mailto:will@wnelson.xyz), [Xander Rudelis](mailto:xander.rudelis@gmail.com), [e-matteson](mailto:e.r.matteson@gmail.com), and [kmkzt](mailto:info.pscreator@gmail.com) | Apache-2.0 or MIT | +| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.13.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | +| [svg](https://github.com/bodoni/svg) | 0.15.1 | [Adam Bryant](mailto:adam.w.bryant@outlook.com), [Felix Schütt](mailto:felix.schuett@maps4print.com), [Felix Zwettler](mailto:f.zwettler@posteo.de), [GeoffreyY](mailto:yeungchingho123@gmail.com), [Gijs Burghoorn](mailto:g.burghoorn@gmail.com), [Ivan Ukhov](mailto:ivan.ukhov@gmail.com), [Jack Greenbaum](mailto:j.greenbaum@computer.org), [Mike Wilkerson](mailto:mwilkerson@gmail.com), [Nathan Hüsken](mailto:nathan@wintercloud.de), [Nathaniel Cook](mailto:nvcook42@gmail.com), [Nick Angelou](mailto:angelou.nick@gmail.com), [Nicolas Silva](mailto:nical@fastmail.com), [Nor Khasyatillah](mailto:mazznoer@ymail.com), [OCTronics](mailto:octronics@riseup.net), [Patrick Chieppe](mailto:patrick.chieppe@hotmail.com), [Will Nelson](mailto:will@wnelson.xyz), [Xander Rudelis](mailto:xander.rudelis@gmail.com), [e-matteson](mailto:e.r.matteson@gmail.com), and [kmkzt](mailto:info.pscreator@gmail.com) | Apache-2.0 or MIT | | [tempfile](https://github.com/Stebalien/tempfile) | 3.10.0 | [Steven Allen](mailto:steven@stebalien.com), The Rust Project Developers, [Ashley Mannix](mailto:ashleymannix@live.com.au), and [Jason White](mailto:me@jasonwhite.io) | Apache-2.0 or MIT | | [write_atomic](https://github.com/Blobfolio/write_atomic) | 0.5.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | | [zerocopy](https://github.com/google/zerocopy) | 0.7.32 | [Joshua Liebow-Feeser](mailto:joshlf@google.com) | Apache-2.0, BSD-2-Clause, or MIT | diff --git a/Cargo.toml b/Cargo.toml index cae35a3..ece3c42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,9 @@ [package] name = "yesvgmap" -version = "0.5.2" +version = "0.5.3" license = "WTFPL" authors = ["Josh Stoik "] edition = "2021" -rust-version = "1.73" description = "Generate SVG sprite maps from individual SVG images." repository = "https://github.com/Blobfolio/yesvgmap" readme = "README.md" @@ -83,13 +82,14 @@ label = "" description = "One or more file and/or directory paths to crunch and/or (recursively) crawl. Only files with the extension .svg will ultimately be included." [build-dependencies] -dowser = "0.8.*" +dowser = "0.9.*" [dependencies] argyle = "0.7.*" -dowser = "0.8.*" -fyi_msg = "0.12.*" -svg = "=0.15.0" +dactyl = "0.7.*" +dowser = "0.9.*" +fyi_msg = "0.13.*" +svg = "=0.15.1" write_atomic = "0.5.*" [profile.release] diff --git a/release/man/yesvgmap.1 b/release/man/yesvgmap.1 index eca4138..97523cb 100644 --- a/release/man/yesvgmap.1 +++ b/release/man/yesvgmap.1 @@ -1,6 +1,6 @@ -.TH "YESVGMAP" "1" "February 2024" "Yesvgmap v0.5.2" "User Commands" +.TH "YESVGMAP" "1" "February 2024" "Yesvgmap v0.5.3" "User Commands" .SH NAME -Yesvgmap \- Manual page for yesvgmap v0.5.2. +Yesvgmap \- Manual page for yesvgmap v0.5.3. .SH DESCRIPTION Generate SVG sprite maps from individual SVG images. .SS USAGE: diff --git a/src/error.rs b/src/error.rs index 2b3cf6f..31eae49 100644 --- a/src/error.rs +++ b/src/error.rs @@ -18,7 +18,7 @@ pub(super) enum SvgError { Argue(ArgyleError), /// # Duplicate entry. - Duplicate, + Duplicate(String), /// # No SVGs. NoSvgs, @@ -41,6 +41,7 @@ impl Error for SvgError {} impl fmt::Display for SvgError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { + Self::Duplicate(s) => write!(f, "Normalized name collision: {s}."), Self::Parse(p) => write!(f, "Unable to parse: {p:?}."), Self::Read(p) => write!(f, "Unreadable: {p:?}."), Self::Viewbox(p) => write!(f, "Missing viewBox: {p:?}"), @@ -59,7 +60,6 @@ impl SvgError { pub(super) const fn as_str(&self) -> &'static str { match self { Self::Argue(e) => e.as_str(), - Self::Duplicate => "Normalized file names must be unique.", Self::NoSvgs => "No SVGs were found.", Self::Write => "Unable to save the SVG map.", _ => "", diff --git a/src/img.rs b/src/img.rs index 8ff64e6..a5fc9e9 100644 --- a/src/img.rs +++ b/src/img.rs @@ -5,6 +5,7 @@ use crate::SvgError; use fyi_msg::Msg; use std::{ + collections::BTreeMap, fmt, path::{ Path, @@ -77,7 +78,6 @@ impl fmt::Display for Map { impl Map { /// # New. pub(super) fn new( - quiet: bool, id: Option<&str>, class: Option<&str>, hide: HideType, @@ -114,7 +114,7 @@ impl Map { // Handle the paths! let mut warned: Vec = Vec::new(); let len: usize = paths.len(); - let mut nice_paths: Vec<(String, Symbol)> = Vec::with_capacity(len); + let mut nice_paths: BTreeMap = BTreeMap::default(); for path in paths { // The symbol ID is built from the alphanumeric (and dash) // characters in the file name. @@ -129,36 +129,29 @@ impl Map { let (s, warn) = parse_as_symbol(&path, &stem, prefix)?; // Push it to temporary storage. - nice_paths.push((stem, s)); + if nice_paths.insert(stem.clone(), s).is_some() { + return Err(SvgError::Duplicate(stem)); + } // Note if this has styles or other issues. - if warn && ! quiet { + if warn { warned.push(path.file_name().unwrap().to_string_lossy().into_owned()); } } - // Sort and dedup by stem. - nice_paths.sort_by(|a, b| a.0.cmp(&b.0)); - nice_paths.dedup_by(|a, b| a.0 == b.0); - - // If the length changed, there are duplicates. - if nice_paths.len() != len { - return Err(SvgError::Duplicate); - } - // Mention any potential style/class issues. if ! warned.is_empty() { - Msg::warning("The following SVG(s) contain scripts, styles, classes, and/or IDs that might -not work correctly when embedded in a sprite map. If you experience issues, -remove those elements from the source(s), then regenerate the map.") - .print(); + Msg::warning(format!( + "Scripts, styles, classes, and IDs may not work correctly in sprite map +contexts; the following image{} might need to be refactored:", + if len == 1 { "" } else { "s" }, + )) + .eprint(); warned.sort(); for w in warned { - println!(" \x1b[1;95m•\x1b[0m {w}"); + eprintln!(" \x1b[1;93m•\x1b[0m {w}"); } - - println!(); } // Done! diff --git a/src/main.rs b/src/main.rs index af1ba0c..6994b10 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,6 +42,7 @@ use argyle::{ FLAG_REQUIRED, FLAG_VERSION, }; +use dactyl::traits::NiceInflection; use dowser::{ Dowser, Extension, @@ -109,7 +110,6 @@ fn _main() -> Result<(), SvgError> { // Find the files! let map = Map::new( - out.is_none(), // Don't print warnings if we're using STDOUT. id, class, hide, @@ -125,13 +125,20 @@ fn _main() -> Result<(), SvgError> { .map_err(|_| SvgError::Write)?; Msg::success(format!( - "A sprite with {} images has been saved to {:?}", - map.len(), + "A sprite with {} has been saved to {:?}", + map.len().nice_inflect("image", "images"), std::fs::canonicalize(&path).unwrap() - )).print(); + )).eprint(); } // Just print it. - else { println!("{map}"); } + else { + Msg::success(format!( + "Generated a sprite with {}.", + map.len().nice_inflect("image", "images"), + )).eprint(); + + println!("{map}"); + } // Done! Ok(())