Skip to content

Commit

Permalink
release: 0.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Oct 18, 2024
2 parents b023aae + 559e206 commit 4a44ea5
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 142 deletions.
16 changes: 8 additions & 8 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Project Dependencies
Package: yesvgmap
Version: 0.5.6
Generated: 2024-09-06 03:01:39 UTC
Version: 0.5.7
Generated: 2024-10-18 03:14:56 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.11 | [Tom Kaitchuck](mailto:[email protected]) | Apache-2.0 or MIT |
| [argyle](https://github.com/Blobfolio/argyle) | 0.8.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [argyle](https://github.com/Blobfolio/argyle) | 0.10.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.4 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dowser](https://github.com/Blobfolio/dowser) | 0.9.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [fastrand](https://github.com/smol-rs/fastrand) | 2.1.1 | [Stjepan Glavina](mailto:[email protected]) | Apache-2.0 or MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.14.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [once_cell](https://github.com/matklad/once_cell) | 1.19.0 | [Aleksey Kladov](mailto:[email protected]) | Apache-2.0 or MIT |
| [svg](https://github.com/bodoni/svg) | 0.17.0 | [Adam Bryant](mailto:[email protected]), [Felix Schütt](mailto:[email protected]), [Felix Zwettler](mailto:[email protected]), [GeoffreyY](mailto:[email protected]), [Gijs Burghoorn](mailto:[email protected]), [Ivan Ukhov](mailto:[email protected]), [Jack Greenbaum](mailto:[email protected]), [Mike Wilkerson](mailto:[email protected]), [Nathan Hüsken](mailto:[email protected]), [Nathaniel Cook](mailto:[email protected]), [Nick Angelou](mailto:[email protected]), [Nicolas Silva](mailto:[email protected]), [Nor Khasyatillah](mailto:[email protected]), [OCTronics](mailto:[email protected]), [Patrick Chieppe](mailto:[email protected]), [Will Nelson](mailto:[email protected]), [Xander Rudelis](mailto:[email protected]), [e-matteson](mailto:[email protected]), and [kmkzt](mailto:[email protected]) | Apache-2.0 or MIT |
| [tempfile](https://github.com/Stebalien/tempfile) | 3.12.0 | [Steven Allen](mailto:[email protected]), The Rust Project Developers, [Ashley Mannix](mailto:[email protected]), and [Jason White](mailto:[email protected]) | Apache-2.0 or MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 1.1.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [once_cell](https://github.com/matklad/once_cell) | 1.20.2 | [Aleksey Kladov](mailto:[email protected]) | Apache-2.0 or MIT |
| [svg](https://github.com/bodoni/svg) | 0.18.0 | [Adam Bryant](mailto:[email protected]), [Felix Schütt](mailto:[email protected]), [Felix Zwettler](mailto:[email protected]), [GeoffreyY](mailto:[email protected]), [Gijs Burghoorn](mailto:[email protected]), [Ivan Ukhov](mailto:[email protected]), [Jack Greenbaum](mailto:[email protected]), [Joshua Klein](mailto:[email protected]), [Mike Wilkerson](mailto:[email protected]), [Nathan Hüsken](mailto:[email protected]), [Nathaniel Cook](mailto:[email protected]), [Nick Angelou](mailto:[email protected]), [Nicolas Silva](mailto:[email protected]), [Nor Khasyatillah](mailto:[email protected]), [OCTronics](mailto:[email protected]), [Patrick Chieppe](mailto:[email protected]), [Will Nelson](mailto:[email protected]), [Xander Rudelis](mailto:[email protected]), [e-matteson](mailto:[email protected]), and [kmkzt](mailto:[email protected]) | Apache-2.0 or MIT |
| [tempfile](https://github.com/Stebalien/tempfile) | 3.13.0 | [Steven Allen](mailto:[email protected]), The Rust Project Developers, [Ashley Mannix](mailto:[email protected]), and [Jason White](mailto:[email protected]) | Apache-2.0 or MIT |
| [write_atomic](https://github.com/Blobfolio/write_atomic) | 0.5.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [zerocopy](https://github.com/google/zerocopy) | 0.7.35 | [Joshua Liebow-Feeser](mailto:[email protected]) | Apache-2.0, BSD-2-Clause, or MIT |
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yesvgmap"
version = "0.5.6"
version = "0.5.7"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
Expand Down Expand Up @@ -82,14 +82,15 @@ label = "<PATH(s)…>"
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]
argyle = "0.10.*"
dowser = "0.9.*"

[dependencies]
argyle = "0.8.*"
argyle = "0.10.*"
dactyl = "0.7.*"
dowser = "0.9.*"
fyi_msg = "0.14.*"
svg = "=0.17.0"
fyi_msg = "1.1.*"
svg = "=0.18.0"
write_atomic = "0.5.*"

[profile.release]
Expand Down
43 changes: 37 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,64 @@
# Yesvgmap: Build
*/

use argyle::KeyWordsBuilder;
use dowser::Extension;
use std::{
fs::File,
io::Write,
path::Path,
path::{
Path,
PathBuf,
},
};



/// # Build.
///
/// We might as well pre-compile the extensions we're looking for.
/// We might as well pre-compile the CLI keys and extensions we're looking for.
pub fn main() {
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");

build_cli();

// Extensions are easy for this one!.
let out = format!(
"/// # Extension: SVG.\nconst E_SVG: Extension = {};",
Extension::codegen(b"svg"),
);
write(&out_path("yesvgmap-extensions.rs"), out.as_bytes());
}

let out_path = std::fs::canonicalize(std::env::var("OUT_DIR").expect("Missing OUT_DIR."))
.expect("Missing OUT_DIR.")
.join("yesvgmap-extensions.rs");
/// # Build CLI Keys.
fn build_cli() {
let mut builder = KeyWordsBuilder::default();
builder.push_keys([
"-h", "--help",
"--hidden",
"--offscreen",
"-V", "--version",
]);
builder.push_keys_with_values([
"-l", "--list",
"--map-class",
"--map-id",
"-o", "--output",
"-p", "--prefix",
]);
builder.save(out_path("argyle.rs"));
}

write(&out_path, out.as_bytes());
/// # Output Path.
///
/// Append the sub-path to OUT_DIR and return it.
fn out_path(stub: &str) -> PathBuf {
std::fs::canonicalize(std::env::var("OUT_DIR").expect("Missing OUT_DIR."))
.expect("Missing OUT_DIR.")
.join(stub)
}


/// # Write File.
fn write(path: &Path, data: &[u8]) {
File::create(path).and_then(|mut f| f.write_all(data).and_then(|_| f.flush()))
Expand Down
2 changes: 1 addition & 1 deletion release/completions/yesvgmap.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _basher___yesvgmap() {
return 0
fi
case "${prev}" in
-l|-o|--list|--output)
--list|--output|-l|-o)
if [ -z "$( declare -f _filedir )" ]; then
COMPREPLY=( $( compgen -f "${cur}" ) )
else
Expand Down
4 changes: 2 additions & 2 deletions release/man/yesvgmap.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "YESVGMAP" "1" "September 2024" "Yesvgmap v0.5.6" "User Commands"
.TH "YESVGMAP" "1" "October 2024" "yesvgmap v0.5.7" "User Commands"
.SH NAME
Yesvgmap \- Manual page for yesvgmap v0.5.6.
YESVGMAP \- Manual page for yesvgmap v0.5.7.
.SH DESCRIPTION
Generate SVG sprite maps from individual SVG images.
.SS USAGE:
Expand Down
80 changes: 70 additions & 10 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Yesvgmap: Errors
*/

use argyle::ArgyleError;
use std::{
error::Error,
fmt,
Expand All @@ -11,12 +10,71 @@ use std::{



/// # Help Text.
const HELP: &str = concat!(r#"
.--. _,
.--; \ /(_
/ '. | '-._ . ' .
| \ \ ,-.) -= * =-
\ /\_ '. \((` .( '/. '
)\ / \ )\ _/ _/
/ \\ .-' '--. /_\
| \\_.' , \/||
\ \_.-';,_) _)'\ \||
'. /`\ ( '._/
`\ .; | . '.
).' )/| \
` ` | \| | "#, "\x1b[38;5;199mYesvgmap\x1b[0;38;5;69m v", env!("CARGO_PKG_VERSION"), "\x1b[0m", r#"
\ | | SVG sprite generator.
'.| |
\ '\__
`-._ '. _
\`;-.` `._
\ \ `'-._\
\ |
\ )
\_\
USAGE:
yesvgmap [FLAGS] [OPTIONS] <PATH(S)>
FLAGS:
-h, --help Print help information and exit.
--hidden Hide the map using the "hidden" HTML attribute.
This takes priority over --offscreen when both
are present.
--offscreen Hide the map using inline styles to position it
offscreen.
-V, --version Print version information and exit.
OPTIONS:
-l, --list <FILE> Read (absolute) file and/or directory paths
from this text file — or STDIN if "-" — one
entry per line, instead of or addition to
(actually trailing) <PATH(S)>.
--map-class <CLASS> Add this class to the generated SVG map.
[default: ]
--map-id <ID> Add this ID to the generated SVG map.
[default: ]
-o, --output <PATH> Save the generated map to this location. If
omitted, the map will print to STDOUT instead.
-p, --prefix <STRING> Set a custom prefix for the IDs of each entry
in the map. (IDs look like PREFIX-STEM, where
STEM is the alphanumeric portion of the source
file name, e.g. "i-close".) [default: i]
ARGS:
<PATH(S)>... One or more file and/or directory paths to
crunch and/or (recursively) crawl. Only files
with the extension .svg will ultimately be
included.
"#);



#[derive(Debug, Clone)]
/// # Error type.
pub(super) enum SvgError {
/// # Argyle passthrough.
Argue(ArgyleError),

/// # Duplicate entry.
Duplicate(String),

Expand All @@ -34,6 +92,12 @@ pub(super) enum SvgError {

/// # Write.
Write,

/// # Print Help (Not an Error).
PrintHelp,

/// # Print Version (Not an Error).
PrintVersion,
}

impl Error for SvgError {}
Expand All @@ -50,18 +114,14 @@ impl fmt::Display for SvgError {
}
}

impl From<ArgyleError> for SvgError {
#[inline]
fn from(err: ArgyleError) -> Self { Self::Argue(err) }
}

impl SvgError {
/// # As Str.
pub(super) const fn as_str(&self) -> &'static str {
match self {
Self::Argue(e) => e.as_str(),
Self::NoSvgs => "No SVGs were found.",
Self::Write => "Unable to save the SVG map.",
Self::PrintHelp => HELP,
Self::PrintVersion => concat!("Yesvgmap v", env!("CARGO_PKG_VERSION")),
_ => "",
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn is_empty(src: &Element) -> bool {
src.get_attributes().is_empty() &&
src.get_children().is_empty() &&
matches!(
src.get_name().as_str(),
src.get_name(),
"a" | "defs" | "glyph" | "g" | "marker" | "mask" | "missing-glyph" |
"pattern" | "script" | "style" | "switch"
)
Expand Down
Loading

0 comments on commit 4a44ea5

Please sign in to comment.