-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BSD tagging support to b3sum #242
Comments
Seems reasonable enough. Would you be willing to submit a PR? If I understand correctly, the main change would be replacing this print statement with two different ways to print: Line 316 in 7692ba5
|
Thanks for the quick reply. I'm not familiar with programming languages outside of shell scripts and basic Python scripts, so I won't be of much help there, sorry. Looking over digest.c in GNU coreutils' |
There is more to it. How about this? diff --git a/b3sum/src/main.rs b/b3sum/src/main.rs
index 0b692a2..23dc098 100644
--- a/b3sum/src/main.rs
+++ b/b3sum/src/main.rs
@@ -22,4 +22,5 @@ const NUM_THREADS_ARG: &str = "num-threads";
const RAW_ARG: &str = "raw";
const CHECK_ARG: &str = "check";
+const TAG_ARG: &str = "tag";
const QUIET_ARG: &str = "quiet";
@@ -115,4 +116,9 @@ impl Args {
),
)
+ .arg(
+ Arg::new(TAG_ARG)
+ .long(TAG_ARG)
+ .help("Create a BSD-style checksum."),
+ )
// wild::args_os() is equivalent to std::env::args_os() on Unix,
// but on Windows it adds support for globbing.
@@ -158,4 +164,8 @@ impl Args {
}
+ fn tag(&self) -> bool {
+ self.inner.is_present(TAG_ARG)
+ }
+
fn raw(&self) -> bool {
self.inner.is_present(RAW_ARG)
@@ -315,4 +325,7 @@ fn write_hex_output(mut output: blake3::OutputReader, args: &Args) -> Result<()>
let take_bytes = cmp::min(len, block.len() as u64);
print!("{}", &hex_str[..2 * take_bytes as usize]);
+ if args.tag() {
+ print!("\n");
+ }
len -= take_bytes;
}
@@ -515,6 +528,11 @@ fn hash_one_input(path: &Path, args: &Args) -> Result<()> {
print!("\\");
}
- write_hex_output(output, args)?;
- println!(" {}", filepath_string);
+ if args.tag() {
+ print!("BLAKE3 ({}) = ", filepath_string);
+ write_hex_output(output, args)?;
+ } else {
+ write_hex_output(output, args)?;
+ println!(" {}", filepath_string);
+ }
Ok(())
} Example:
I do not know Rust and I might have missed something. I suppose you could just pass @systwi-again: would this suffice? |
@odiferousmint Looks good, thanks for the help! |
I came here to request the same feature, anything blocking this? |
Title pretty much says it all. Could this feature be added to
b3sum
, please?Visual example:
The text was updated successfully, but these errors were encountered: