diff options
| author | Leah Neukirchen <[email protected]> | 2025-02-28 16:38:16 +0100 |
|---|---|---|
| committer | Leah Neukirchen <[email protected]> | 2025-02-28 16:39:35 +0100 |
| commit | cd6fdc3e03b0143f0e2a4d7537f58e595cf7cc0b (patch) | |
| tree | 8df0535726c592b98c5de49782efd15385c1b388 | |
| parent | 0f9dc2706f931366632a378a95b348e3cb40ed01 (diff) | |
b3sum: add --tag
| -rw-r--r-- | b3sum/src/main.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/b3sum/src/main.rs b/b3sum/src/main.rs index baa6b6c..b10cff8 100644 --- a/b3sum/src/main.rs +++ b/b3sum/src/main.rs @@ -16,6 +16,7 @@ const KEYED_ARG: &str = "keyed"; const LENGTH_ARG: &str = "length"; const NO_NAMES_ARG: &str = "no_names"; const RAW_ARG: &str = "raw"; +const TAG_ARG: &str = "tag"; const CHECK_ARG: &str = "check"; #[derive(Parser)] @@ -72,6 +73,10 @@ struct Inner { #[arg(long)] raw: bool, + /// Prefix output with `BLAKE3 (...) =` + #[arg(long)] + tag: bool, + /// Read BLAKE3 sums from the [FILE]s and check them #[arg( short, @@ -80,6 +85,7 @@ struct Inner { conflicts_with(KEYED_ARG), conflicts_with(LENGTH_ARG), conflicts_with(RAW_ARG), + conflicts_with(TAG_ARG), conflicts_with(NO_NAMES_ARG) )] check: bool, @@ -138,6 +144,10 @@ impl Args { self.inner.raw } + fn tag(&self) -> bool { + self.inner.tag + } + fn no_mmap(&self) -> bool { self.inner.no_mmap } @@ -393,6 +403,12 @@ fn hash_one_input(path: &Path, args: &Args) -> Result<()> { if is_escaped { print!("\\"); } + if args.tag() { + print!("BLAKE3 ({}) = ", filepath_string); + write_hex_output(output, args)?; + println!(); + return Ok(()); + } write_hex_output(output, args)?; println!(" {}", filepath_string); Ok(()) |
