shadow_crypt_shell/listing/
cli.rs

1use clap::{Parser, error::ErrorKind};
2
3use crate::errors::WorkflowError;
4
5/// Listing CLI arguments structure
6#[derive(Debug, Clone, Parser)]
7#[command(
8    name = "shadows",
9    about = "List shadow files in the current directory",
10    version
11)]
12pub struct ListingCliArgs {}
13
14/// Parse listing command line arguments
15pub fn get_cli_args(args: Vec<String>) -> Result<ListingCliArgs, WorkflowError> {
16    ListingCliArgs::try_parse_from(args).map_err(|e| {
17        // If it's help or version, it's not a user input error
18        if e.kind() == ErrorKind::DisplayHelp || e.kind() == ErrorKind::DisplayVersion {
19            // Print the message and exit successfully
20            eprintln!("{}", e);
21            std::process::exit(0);
22        }
23        WorkflowError::UserInput(e.to_string())
24    })
25}