@@ -52,9 +52,6 @@ pub enum CliCommand {
5252 /// Remove all generated output files and directories
5353 Clean ( CleanArgs ) ,
5454
55- /// Set or show configuration values
56- Config ( ConfigArgs ) ,
57-
5855 /// List all registered plugins
5956 Plugins ,
6057}
@@ -66,20 +63,6 @@ pub struct CleanArgs {
6663 pub dry_run : bool ,
6764}
6865
69- #[ derive( Args , Debug ) ]
70- pub struct ConfigArgs {
71- /// Show merged configuration as JSON
72- #[ arg( long = "show" ) ]
73- pub show : bool ,
74-
75- /// Configuration key=value pairs to set
76- #[ arg( long = "set" , value_name = "KEY=VALUE" ) ]
77- pub set : Vec < String > ,
78-
79- /// Positional key=value pairs
80- pub positional : Vec < String > ,
81- }
82-
8366/// Resolved log level from CLI flags.
8467/// When multiple flags are provided, the most verbose wins.
8568#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
@@ -161,34 +144,9 @@ pub enum ResolvedCommand {
161144 DryRun ,
162145 Clean ,
163146 DryRunClean ,
164- Config ( Vec < ( String , String ) > ) ,
165- ConfigShow ,
166147 Plugins ,
167148}
168149
169- /// Parse --set and positional key=value pairs into (key, value) tuples.
170- fn parse_key_value_pairs ( args : & ConfigArgs ) -> Vec < ( String , String ) > {
171- let mut pairs = Vec :: new ( ) ;
172-
173- for s in & args. set {
174- if let Some ( eq_idx) = s. find ( '=' )
175- && eq_idx > 0
176- {
177- pairs. push ( ( s[ ..eq_idx] . to_string ( ) , s[ eq_idx + 1 ..] . to_string ( ) ) ) ;
178- }
179- }
180-
181- for s in & args. positional {
182- if let Some ( eq_idx) = s. find ( '=' )
183- && eq_idx > 0
184- {
185- pairs. push ( ( s[ ..eq_idx] . to_string ( ) , s[ eq_idx + 1 ..] . to_string ( ) ) ) ;
186- }
187- }
188-
189- pairs
190- }
191-
192150/// Resolve the command to execute from parsed CLI args.
193151pub fn resolve_command ( cli : & Cli ) -> ResolvedCommand {
194152 match & cli. command {
@@ -203,18 +161,6 @@ pub fn resolve_command(cli: &Cli) -> ResolvedCommand {
203161 ResolvedCommand :: Clean
204162 }
205163 }
206- Some ( CliCommand :: Config ( args) ) => {
207- if args. show {
208- ResolvedCommand :: ConfigShow
209- } else {
210- let pairs = parse_key_value_pairs ( args) ;
211- if pairs. is_empty ( ) {
212- ResolvedCommand :: Execute
213- } else {
214- ResolvedCommand :: Config ( pairs)
215- }
216- }
217- }
218164 Some ( CliCommand :: Plugins ) => ResolvedCommand :: Plugins ,
219165 }
220166}
@@ -235,23 +181,4 @@ mod tests {
235181 let cli = Cli :: parse_from ( [ "tnmsc" , "clean" , "--dry-run" ] ) ;
236182 assert_eq ! ( resolve_command( & cli) , ResolvedCommand :: DryRunClean ) ;
237183 }
238-
239- #[ test]
240- fn config_key_value_parsing_combines_flag_and_positional_pairs ( ) {
241- let cli = Cli :: parse_from ( [
242- "tnmsc" ,
243- "config" ,
244- "--set" ,
245- "workspaceDir=/tmp/workspace" ,
246- "logLevel=debug" ,
247- ] ) ;
248-
249- assert_eq ! (
250- resolve_command( & cli) ,
251- ResolvedCommand :: Config ( vec![
252- ( "workspaceDir" . to_string( ) , "/tmp/workspace" . to_string( ) ) ,
253- ( "logLevel" . to_string( ) , "debug" . to_string( ) ) ,
254- ] )
255- ) ;
256- }
257184}
0 commit comments