1use clap::Parser;
2
3#[derive(Parser)]
4#[command(name = "jsonhash")]
5#[command(about = "Compute hash of file content and filepath. Supports SHA256 and MD5. Returns as Json", long_about = None)]
6pub struct Cli {
7 #[arg(value_name = "FILEPATH")]
8 pub filepath: String,
9
10 #[arg(short = 'a', long = "alg", default_value = "sha256", value_name = "ALGORITHM")]
11 pub algorithm: String,
12}
13
14pub fn validate_algorithm(alg: &str) -> Result<(), String> {
15 match alg.to_lowercase().as_str() {
16 "sha256" | "md5" => Ok(()),
17 _ => Err("HASH-ALGORITHM-INVALID".to_string()),
18 }
19}