Improve CLI
This commit is contained in:
parent
b704f51940
commit
a5263993a1
|
@ -42,7 +42,7 @@ Precompiled binaries are available for 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 --css --js
|
||||
minify-html --output /path/to/output.min.html --keep-closing-tags --minify-css /path/to/src.html
|
||||
```
|
||||
|
||||
</details>
|
||||
|
|
|
@ -13,11 +13,11 @@ use minify_html::{minify, Cfg};
|
|||
// WARNING: Keep descriptions in sync with Cfg.
|
||||
struct Cli {
|
||||
/// File to minify; omit for stdin.
|
||||
#[structopt(short, long, parse(from_os_str))]
|
||||
src: Option<std::path::PathBuf>,
|
||||
#[structopt(parse(from_os_str))]
|
||||
input: Option<std::path::PathBuf>,
|
||||
/// Output destination; omit for stdout.
|
||||
#[structopt(short, long, parse(from_os_str))]
|
||||
out: Option<std::path::PathBuf>,
|
||||
output: Option<std::path::PathBuf>,
|
||||
/// Minify JS in `<script>` tags that have a valid or no `type` attribute value.
|
||||
#[structopt(long)]
|
||||
minify_js: bool,
|
||||
|
@ -63,7 +63,7 @@ macro_rules! io_expect {
|
|||
fn main() {
|
||||
let args = Cli::from_args();
|
||||
let mut src_code = Vec::<u8>::new();
|
||||
let mut src_file: Box<dyn Read> = match args.src {
|
||||
let mut src_file: Box<dyn Read> = match args.input {
|
||||
Some(p) => Box::new(io_expect!(File::open(p), "could not open source file")),
|
||||
None => Box::new(stdin()),
|
||||
};
|
||||
|
@ -85,7 +85,7 @@ fn main() {
|
|||
remove_processing_instructions: args.remove_processing_instructions,
|
||||
},
|
||||
);
|
||||
let mut out_file: Box<dyn Write> = match args.out {
|
||||
let mut out_file: Box<dyn Write> = match args.output {
|
||||
Some(p) => Box::new(io_expect!(File::create(p), "could not open output file")),
|
||||
None => Box::new(stdout()),
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue