diff --git a/README.md b/README.md index 4450d95..61937ab 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Precompiled binaries are available for x86-64 Linux, macOS, and Windows. Use the `--help` argument for more details. ```bash -minify-html --src /path/to/src.html --out /path/to/output.min.html +minify-html --src /path/to/src.html --out /path/to/output.min.html --css --js ``` ### API diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 04cb5ae..6d4a8c7 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,7 @@ [package] publish = false name = "minify-html-cli" +description = "Extremely fast and smart HTML + JS + CSS minifier" version = "0.4.0" authors = ["Wilson Lin "] edition = "2018" diff --git a/cli/src/main.rs b/cli/src/main.rs index 0ffbedf..a9d18b5 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -6,13 +6,18 @@ use structopt::StructOpt; use minify_html::{Cfg, FriendlyError, with_friendly_error}; #[derive(StructOpt)] +#[structopt(name = "minify-html", about = "Extremely fast and smart HTML + JS + CSS minifier")] struct Cli { + /// File to minify; omit for stdin. #[structopt(short, long, parse(from_os_str))] src: Option, + /// Output destination; omit for stdout. #[structopt(short, long, parse(from_os_str))] out: Option, + /// Enables JS minification. #[structopt(long)] js: bool, + /// Enables CSS minification. #[structopt(long)] css: bool, } diff --git a/ruby/src/lib.rs b/ruby/src/lib.rs index f1a88b2..915200b 100644 --- a/ruby/src/lib.rs +++ b/ruby/src/lib.rs @@ -15,14 +15,18 @@ methods! { .to_string() .into_bytes(); + let cfg_hash = cfg_hash + .map_err(|e| VM::raise_ex(e) ) + .unwrap(); + let cfg = &Cfg { minify_js: cfg_hash - .map(|h| h.at(&Symbol::new("minify_js"))) - .and_then(|e| e.try_convert_to::()) + .at(&Symbol::new("minify_js")) + .try_convert_to::() .map_or(false, |v| v.to_bool()), minify_css: cfg_hash - .map(|h| h.at(&Symbol::new("minify_css"))) - .and_then(|e| e.try_convert_to::()) + .at(&Symbol::new("minify_css")) + .try_convert_to::() .map_or(false, |v| v.to_bool()), };