Skip to content

Commit

Permalink
improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
magiclen committed Nov 11, 2023
1 parent 9e15181 commit 2fa59bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xcompress"
version = "0.12.4"
version = "0.12.5"
authors = ["Magic Len <[email protected]>"]
edition = "2021"
rust-version = "1.70"
Expand Down
2 changes: 1 addition & 1 deletion src/commands/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn handle_compression(cli_args: CLIArgs) -> anyhow::Result<()> {
},
Err(error) => {
return Err(error)
.with_context(|| format!("{:?}", input_path.absolutize().unwrap()));
.with_context(|| anyhow!("{:?}", input_path.absolutize().unwrap()));
},
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/commands/decompression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn handle_decompression(cli_args: CLIArgs) -> anyhow::Result<()> {
Ok(input_path) => input_path,
Err(error) => {
return Err(error)
.with_context(|| format!("{:?}", input_path.absolutize().unwrap()));
.with_context(|| anyhow!("{:?}", input_path.absolutize().unwrap()));
},
};

Expand Down Expand Up @@ -58,15 +58,15 @@ pub fn handle_decompression(cli_args: CLIArgs) -> anyhow::Result<()> {
},
Err(error) if error.kind() == io::ErrorKind::NotFound => {
fs::create_dir_all(output_path)
.with_context(|| format!("{:?}", output_path.absolutize().unwrap()))?;
.with_context(|| anyhow!("{:?}", output_path.absolutize().unwrap()))?;

output_path
.canonicalize()
.with_context(|| format!("{:?}", output_path.absolutize().unwrap()))?
.with_context(|| anyhow!("{:?}", output_path.absolutize().unwrap()))?
},
Err(error) => {
return Err(error)
.with_context(|| format!("{:?}", output_path.absolutize().unwrap()));
.with_context(|| anyhow!("{:?}", output_path.absolutize().unwrap()));
},
};

Expand Down Expand Up @@ -538,7 +538,7 @@ pub fn handle_decompression(cli_args: CLIArgs) -> anyhow::Result<()> {
}

let file =
File::create(file_path.as_path()).with_context(|| format!("{file_path:?}"))?;
File::create(file_path.as_path()).with_context(|| anyhow!("{file_path:?}"))?;

if cpus > 1
&& command_args!(&cli_args.executable_paths.pigz_path, "-V")
Expand Down Expand Up @@ -592,7 +592,7 @@ pub fn handle_decompression(cli_args: CLIArgs) -> anyhow::Result<()> {
}

let file =
File::create(file_path.as_path()).with_context(|| format!("{file_path:?}"))?;
File::create(file_path.as_path()).with_context(|| anyhow!("{file_path:?}"))?;

if cpus > 1 {
if command_args!(&cli_args.executable_paths.lbzip2_path, "-V")
Expand Down Expand Up @@ -666,7 +666,7 @@ pub fn handle_decompression(cli_args: CLIArgs) -> anyhow::Result<()> {
}

let file =
File::create(file_path.as_path()).with_context(|| format!("{file_path:?}"))?;
File::create(file_path.as_path()).with_context(|| anyhow!("{file_path:?}"))?;

if cpus > 1
&& command_args!(&cli_args.executable_paths.plzip_path, "-V")
Expand Down Expand Up @@ -720,7 +720,7 @@ pub fn handle_decompression(cli_args: CLIArgs) -> anyhow::Result<()> {
}

let file =
File::create(file_path.as_path()).with_context(|| format!("{file_path:?}"))?;
File::create(file_path.as_path()).with_context(|| anyhow!("{file_path:?}"))?;

if cpus > 1
&& command_args!(&cli_args.executable_paths.pxz_path, "-V")
Expand Down Expand Up @@ -774,7 +774,7 @@ pub fn handle_decompression(cli_args: CLIArgs) -> anyhow::Result<()> {
}

let file =
File::create(file_path.as_path()).with_context(|| format!("{file_path:?}"))?;
File::create(file_path.as_path()).with_context(|| anyhow!("{file_path:?}"))?;

if cpus > 1
&& command_args!(&cli_args.executable_paths.pxz_path, "-V")
Expand Down Expand Up @@ -925,7 +925,7 @@ pub fn handle_decompression(cli_args: CLIArgs) -> anyhow::Result<()> {
}

let file =
File::create(file_path.as_path()).with_context(|| format!("{file_path:?}"))?;
File::create(file_path.as_path()).with_context(|| anyhow!("{file_path:?}"))?;

if cpus > 1
&& command_args!(&cli_args.executable_paths.pzstd_path, "-V")
Expand Down

0 comments on commit 2fa59bd

Please sign in to comment.