move combined algorithms to function, add -v to readme

This commit is contained in:
Bryson Steck 2025-08-12 19:37:47 -06:00
parent 317db496cd
commit 633265078f
Signed by: bryson
SSH key fingerprint: SHA256:XpKABw/nP4z8UVaH+weLaBnEOD86+cVwif+QjuYLGT4
2 changed files with 18 additions and 13 deletions

View file

@ -43,6 +43,9 @@ With no FILE(s) specified, or when FILE is a dash (-), picca will read from stan
**-t, ––threads**=_THREADS_ **-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. : 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: The following option is only useful when verifying checksums with the **-c** flag:
**-q, ––quiet** **-q, ––quiet**

View file

@ -92,19 +92,7 @@ struct Args {
long, long,
help = "Specify an algorithm for hashing", help = "Specify an algorithm for hashing",
default_value = "sha256", default_value = "sha256",
value_parser = { value_parser = clap::builder::PossibleValuesParser::new(get_algorithms())
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))
}
)] )]
algorithm: String, algorithm: String,
@ -144,6 +132,20 @@ struct ThreadInfo {
hash_errors: Arc<AtomicI32>, hash_errors: Arc<AtomicI32>,
} }
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> { fn hash(info: ThreadInfo) -> Result<(), String> {
loop { loop {
let mut stdin = None; let mut stdin = None;