mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
Merge pull request #374 from figsoda/fast
This commit is contained in:
commit
2b142ff442
@ -20,6 +20,12 @@ Categories Used:
|
|||||||
|
|
||||||
## [Unreleased](https://github.com/ouch-org/ouch/compare/0.4.1...HEAD)
|
## [Unreleased](https://github.com/ouch-org/ouch/compare/0.4.1...HEAD)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
- Add flags to configure the compression level
|
||||||
|
- `--level` to precisely set the compression level [\#372](https://github.com/ouch-org/ouch/pull/372) ([xgdgsc](https://github.com/xgdgsc))
|
||||||
|
- `--fast` and `--slow` [\#374](https://github.com/ouch-org/ouch/pull/374) ([figsoda](https://github.com/figsoda))
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
||||||
- Multi-threaded compression for gzip and snappy using gzp [\#348](https://github.com/ouch-org/ouch/pull/348) ([figsoda](https://github.com/figsoda))
|
- Multi-threaded compression for gzip and snappy using gzp [\#348](https://github.com/ouch-org/ouch/pull/348) ([figsoda](https://github.com/figsoda))
|
||||||
|
@ -61,8 +61,18 @@ pub enum Subcommand {
|
|||||||
output: PathBuf,
|
output: PathBuf,
|
||||||
|
|
||||||
/// Compression level, applied to all formats
|
/// Compression level, applied to all formats
|
||||||
#[arg(short, long)]
|
#[arg(short, long, group = "compression-level")]
|
||||||
level: Option<i16>,
|
level: Option<i16>,
|
||||||
|
|
||||||
|
/// Fastest compression level possible,
|
||||||
|
/// conflicts with --level and --slow
|
||||||
|
#[arg(long, group = "compression-level")]
|
||||||
|
fast: bool,
|
||||||
|
|
||||||
|
/// Slowest (and best) compression level possible,
|
||||||
|
/// conflicts with --level and --fast
|
||||||
|
#[arg(long, group = "compression-level")]
|
||||||
|
slow: bool,
|
||||||
},
|
},
|
||||||
/// Decompresses one or more files, optionally into another folder
|
/// Decompresses one or more files, optionally into another folder
|
||||||
#[command(visible_alias = "d")]
|
#[command(visible_alias = "d")]
|
||||||
|
@ -45,6 +45,8 @@ pub fn run(
|
|||||||
files,
|
files,
|
||||||
output: output_path,
|
output: output_path,
|
||||||
level,
|
level,
|
||||||
|
fast,
|
||||||
|
slow,
|
||||||
} => {
|
} => {
|
||||||
// After cleaning, if there are no input files left, exit
|
// After cleaning, if there are no input files left, exit
|
||||||
if files.is_empty() {
|
if files.is_empty() {
|
||||||
@ -73,6 +75,14 @@ pub fn run(
|
|||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let level = if fast {
|
||||||
|
Some(1) // Lowest level of compression
|
||||||
|
} else if slow {
|
||||||
|
Some(i16::MAX) // Highest level of compression
|
||||||
|
} else {
|
||||||
|
level
|
||||||
|
};
|
||||||
|
|
||||||
let compress_result = compress_files(
|
let compress_result = compress_files(
|
||||||
files,
|
files,
|
||||||
formats,
|
formats,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user