sub_solver/
cli.rs

1use std::path::PathBuf;
2
3use clap::{ArgGroup, Parser};
4
5/// Substitution Cipher Solver
6#[derive(Parser, Debug)]
7#[command(name = "sub-solver")]
8pub struct Args {
9    #[clap(flatten)]
10    pub ciphertext: Ciphertext,
11
12    /// Path to the wordlist file (default: built-in english.txt)
13    #[arg(short, long)]
14    pub wordlist: Option<String>,
15
16    /// Starting key, letter mapping (default: empty, example: "a:b,c:d,e:f", "ab,cd,ef", "b?d?f?????????????????????")
17    #[arg(short, long)]
18    pub key: Option<String>,
19
20    /// Fill in unknowns in solution with random unused letters (default: false)
21    #[arg(short = 'F', long)]
22    pub fill_key: bool,
23
24    /// Disable dictionary cache (default: false)
25    #[arg(short, long)]
26    pub no_cache: bool,
27}
28
29#[derive(Parser, Debug)]
30#[clap(group = ArgGroup::new("ciphertext").required(true).multiple(false))]
31pub struct Ciphertext {
32    /// Ciphertext string to solve
33    #[clap(group = "ciphertext", short, long)]
34    pub string: Option<String>,
35
36    /// Path to the ciphertext file
37    #[clap(group = "ciphertext", short, long)]
38    pub file: Option<PathBuf>,
39}