Skip to content

Commit

Permalink
cli: Add switch to silence checksum warning, and print warning to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
antangelo committed Mar 17, 2024
1 parent 2a73e49 commit 5328949
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
19 changes: 13 additions & 6 deletions xdvdfs-cli/src/cmd_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@ async fn checksum_single(img_path: &str) -> Result<(), anyhow::Error> {
}

#[maybe_async]
pub async fn cmd_checksum(images: &Vec<String>) -> Result<(), anyhow::Error> {
println!("This SHA256 sum is a condensed checksum of the all the data inside the image");
println!("It does not encode information about the filesystem structure outside of the data being in the correct order.");
println!("Note that this is NOT a SHA256 sum of the full image, and cannot be compared to a SHA256 sum of the full image.");
println!("This checksum is only useful when compared to other checksums created by this tool.");
println!();
pub async fn cmd_checksum(
images: &Vec<String>,
silence_warning: bool,
) -> Result<(), anyhow::Error> {
if !silence_warning {
eprintln!("This SHA256 sum is a condensed checksum of the all the data inside the image");
eprintln!("It does not encode information about the filesystem structure outside of the data being in the correct order.");
eprintln!("Note that this is NOT a SHA256 sum of the full image, and cannot be compared to a SHA256 sum of the full image.");
eprintln!(
"This checksum is only useful when compared to other checksums created by this tool."
);
eprintln!();
}

for image in images {
checksum_single(image).await?;
Expand Down
5 changes: 4 additions & 1 deletion xdvdfs-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ enum Cmd {
Checksum {
#[arg(help = "Path to XISO image")]
images: Vec<String>,

#[arg(short, long, help = "Only output checksums without warnings")]
silent: bool,
},
#[command(
about = "Print information about image metadata",
Expand Down Expand Up @@ -90,7 +93,7 @@ async fn run_command(cmd: &Cmd) -> Result<(), anyhow::Error> {
Ls { image_path, path } => cmd_read::cmd_ls(image_path, path).await,
Tree { image_path } => cmd_read::cmd_tree(image_path).await,
Md5 { image_path, path } => cmd_md5::cmd_md5(image_path, path.clone().as_deref()).await,
Checksum { images } => cmd_read::cmd_checksum(images).await,
Checksum { images, silent } => cmd_read::cmd_checksum(images, *silent).await,
Info {
image_path,
file_entry,
Expand Down

0 comments on commit 5328949

Please sign in to comment.