sakurs_cli/commands/
mod.rs1use clap::Subcommand;
4
5pub mod generate_config;
6pub mod process;
7pub mod validate;
8
9#[derive(Debug, Subcommand)]
11pub enum Commands {
12 Process(process::ProcessArgs),
14
15 Validate(validate::ValidateArgs),
17
18 #[command(name = "generate-config")]
20 GenerateConfig(generate_config::GenerateConfigArgs),
21
22 List {
24 #[command(subcommand)]
25 subcommand: ListCommands,
26 },
27}
28
29#[derive(Debug, Subcommand)]
31pub enum ListCommands {
32 Languages,
34
35 Formats,
37}
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42
43 #[test]
44 fn test_commands_debug_format() {
45 let process_cmd = Commands::Process(process::ProcessArgs {
47 input: vec!["test.txt".to_string()],
48 output: None,
49 format: process::OutputFormat::Text,
50 language: Some(process::Language::English),
51 language_config: None,
52 language_code: None,
53 parallel: false,
54 adaptive: false,
55 threads: None,
56 chunk_kb: None,
57 quiet: false,
58 verbose: 0,
59 stream: false,
60 stream_chunk_mb: 10,
61 });
62
63 let debug_str = format!("{:?}", process_cmd);
64 assert!(debug_str.contains("Process"));
65 assert!(debug_str.contains("test.txt"));
66
67 let list_cmd = Commands::List {
69 subcommand: ListCommands::Languages,
70 };
71
72 let debug_str = format!("{:?}", list_cmd);
73 assert!(debug_str.contains("List"));
74 assert!(debug_str.contains("Languages"));
75 }
76
77 #[test]
78 fn test_list_commands_variants() {
79 let languages = ListCommands::Languages;
81 let debug_str = format!("{:?}", languages);
82 assert!(debug_str.contains("Languages"));
83
84 let formats = ListCommands::Formats;
86 let debug_str = format!("{:?}", formats);
87 assert!(debug_str.contains("Formats"));
88 }
89
90 #[test]
91 fn test_enum_variants_completeness() {
92 let process_cmd = Commands::Process(process::ProcessArgs {
94 input: vec!["test.txt".to_string()],
95 output: None,
96 format: process::OutputFormat::Text,
97 language: Some(process::Language::English),
98 language_config: None,
99 language_code: None,
100 parallel: false,
101 adaptive: false,
102 threads: None,
103 chunk_kb: None,
104 quiet: false,
105 verbose: 0,
106 stream: false,
107 stream_chunk_mb: 10,
108 });
109
110 let list_cmd = Commands::List {
111 subcommand: ListCommands::Languages,
112 };
113
114 match process_cmd {
116 Commands::Process(_) => (),
117 Commands::Validate(_) => panic!("Should be Process"),
118 Commands::GenerateConfig(_) => panic!("Should be Process"),
119 Commands::List { .. } => panic!("Should be Process"),
120 }
121
122 match list_cmd {
123 Commands::Process(_) => panic!("Should be List"),
124 Commands::Validate(_) => panic!("Should be List"),
125 Commands::GenerateConfig(_) => panic!("Should be List"),
126 Commands::List { .. } => (),
127 }
128 }
129
130 #[test]
131 fn test_list_commands_completeness() {
132 match ListCommands::Languages {
134 ListCommands::Languages => (),
135 ListCommands::Formats => panic!("Should be Languages"),
136 }
137
138 match ListCommands::Formats {
139 ListCommands::Languages => panic!("Should be Formats"),
140 ListCommands::Formats => (),
141 }
142 }
143}