From 633265078f18d8644846d14ed8a585f7adb68936 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Tue, 12 Aug 2025 19:37:47 -0600 Subject: [PATCH] move combined algorithms to function, add -v to readme --- man/picca.1.md | 3 +++ src/main.rs | 28 +++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/man/picca.1.md b/man/picca.1.md index f0c47e4..b863b1f 100644 --- a/man/picca.1.md +++ b/man/picca.1.md @@ -43,6 +43,9 @@ With no FILE(s) specified, or when FILE is a dash (-), picca will read from stan **-t, ––threads**=_THREADS_ : Use at most, at any given time, this number of threads. By default, picca will detect the amount of processors on the system and use that as the thread count. Using 0 for this value results in the default behavior; this is the same as omitting this option. +**-V, ––version** +: Show the version of picca and exit + The following option is only useful when verifying checksums with the **-c** flag: **-q, ––quiet** diff --git a/src/main.rs b/src/main.rs index 0ea7ecc..d61e180 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,19 +92,7 @@ struct Args { long, help = "Specify an algorithm for hashing", default_value = "sha256", - value_parser = { - let mut combined: Vec<&str> = vec![]; - for i in ALGORITHMS { - combined.push(i); - } - - for i in UNSECURE_ALGORITHMS { - combined.push(i); - } - combined.sort(); - - clap::builder::PossibleValuesParser::new(Vec::from(combined)) - } + value_parser = clap::builder::PossibleValuesParser::new(get_algorithms()) )] algorithm: String, @@ -144,6 +132,20 @@ struct ThreadInfo { hash_errors: Arc, } +fn get_algorithms() -> Vec<&'static str> { + let mut combined: Vec<&str> = vec![]; + for i in ALGORITHMS { + combined.push(i); + } + + for i in UNSECURE_ALGORITHMS { + combined.push(i); + } + combined.sort(); + + return Vec::from(combined) +} + fn hash(info: ThreadInfo) -> Result<(), String> { loop { let mut stdin = None;