1- use crate :: cli:: { Commands , GlobalOpts , OutputFormat , Priority , Formatter } ;
2- use crate :: config:: ConfigLoader ;
31use crate :: cli:: error:: { CliError , CliResult , EXIT_SUCCESS } ;
4- use tracing:: { info, debug} ;
2+ use crate :: cli:: { Commands , Formatter , GlobalOpts , OutputFormat , Priority } ;
3+ use crate :: config:: ConfigLoader ;
4+ use tracing:: { debug, info} ;
55
66pub struct CommandHandler {
77 global_opts : GlobalOpts ,
@@ -28,7 +28,10 @@ impl CommandHandler {
2828 follow,
2929 dry_run,
3030 ..
31- } ) => self . handle_exec ( & task, priority, timeout, r#async, follow, dry_run) . await ,
31+ } ) => {
32+ self . handle_exec ( & task, priority, timeout, r#async, follow, dry_run)
33+ . await
34+ } ,
3235
3336 Some ( Commands :: Query {
3437 query,
@@ -44,35 +47,35 @@ impl CommandHandler {
4447 ConfigSubcommand :: Get { key } => self . handle_config_get ( & key) . await ,
4548 ConfigSubcommand :: Set { key, value } => {
4649 self . handle_config_set ( & key, & value) . await
47- }
50+ } ,
4851 ConfigSubcommand :: Init { profile } => self . handle_config_init ( & profile) . await ,
4952 ConfigSubcommand :: Validate => self . handle_config_validate ( ) . await ,
5053 ConfigSubcommand :: Reset => self . handle_config_reset ( ) . await ,
5154 }
52- }
55+ } ,
5356
5457 Some ( Commands :: Debug { subcommand } ) => {
5558 use crate :: cli:: commands:: DebugSubcommand ;
5659 match subcommand {
5760 DebugSubcommand :: Status => self . handle_debug_status ( ) . await ,
5861 DebugSubcommand :: BusLatency { num_messages } => {
5962 self . handle_debug_bus_latency ( num_messages) . await
60- }
63+ } ,
6164 DebugSubcommand :: MemoryStats => self . handle_debug_memory_stats ( ) . await ,
6265 DebugSubcommand :: AdapterTest { adapter } => {
6366 self . handle_debug_adapter_test ( & adapter) . await
64- }
67+ } ,
6568 DebugSubcommand :: TraceFlow { task_id } => {
6669 self . handle_debug_trace_flow ( & task_id) . await
67- }
70+ } ,
6871 DebugSubcommand :: Profile { duration } => {
6972 self . handle_debug_profile ( duration) . await
70- }
73+ } ,
7174 DebugSubcommand :: ValidateIntent { text } => {
7275 self . handle_debug_validate_intent ( & text) . await
73- }
76+ } ,
7477 }
75- }
78+ } ,
7679
7780 Some ( Commands :: Repl { .. } ) => self . handle_repl ( ) . await ,
7881
@@ -82,7 +85,7 @@ impl CommandHandler {
8285 println ! ( "MiMi v{}" , env!( "CARGO_PKG_VERSION" ) ) ;
8386 println ! ( "Use 'mimi --help' for usage information" ) ;
8487 Ok ( EXIT_SUCCESS )
85- }
88+ } ,
8689 }
8790 }
8891
@@ -96,10 +99,16 @@ impl CommandHandler {
9699 follow : bool ,
97100 dry_run : bool ,
98101 ) -> CliResult < i32 > {
99- info ! ( "Executing task: {} (priority: {}, timeout: {}s)" , task, priority, timeout) ;
102+ info ! (
103+ "Executing task: {} (priority: {}, timeout: {}s)" ,
104+ task, priority, timeout
105+ ) ;
100106
101107 if dry_run {
102- let msg = format ! ( "DRY RUN: Would execute task '{}' with priority {}" , task, priority) ;
108+ let msg = format ! (
109+ "DRY RUN: Would execute task '{}' with priority {}" ,
110+ task, priority
111+ ) ;
103112 println ! ( "{}" , self . formatter. format_success( & msg) ) ;
104113 return Ok ( EXIT_SUCCESS ) ;
105114 }
@@ -117,7 +126,10 @@ impl CommandHandler {
117126 ) -> CliResult < i32 > {
118127 info ! ( "Querying: {}" , query) ;
119128
120- println ! ( "{}" , self . formatter. format_success( & format!( "Query: {}" , query) ) ) ;
129+ println ! (
130+ "{}" ,
131+ self . formatter. format_success( & format!( "Query: {}" , query) )
132+ ) ;
121133 Ok ( EXIT_SUCCESS )
122134 }
123135
@@ -129,7 +141,15 @@ impl CommandHandler {
129141 ( "log.level" , & config. log. level) ,
130142 ] ;
131143
132- println ! ( "{}" , self . formatter. format_kv( & pairs. iter( ) . map( |( k, v) | ( * k, v. as_str( ) ) ) . collect:: <Vec <_>>( ) ) ) ;
144+ println ! (
145+ "{}" ,
146+ self . formatter. format_kv(
147+ & pairs
148+ . iter( )
149+ . map( |( k, v) | ( * k, v. as_str( ) ) )
150+ . collect:: <Vec <_>>( )
151+ )
152+ ) ;
133153 Ok ( EXIT_SUCCESS )
134154 }
135155
@@ -146,9 +166,17 @@ impl CommandHandler {
146166
147167 if let Some ( path) = & self . global_opts . config {
148168 ConfigLoader :: save ( & config, path) ?;
149- println ! ( "{}" , self . formatter. format_success( & format!( "Set {}: {}" , key, value) ) ) ;
169+ println ! (
170+ "{}" ,
171+ self . formatter
172+ . format_success( & format!( "Set {}: {}" , key, value) )
173+ ) ;
150174 } else {
151- println ! ( "{}" , self . formatter. format_success( "Config set (not saved - specify --config to persist)" ) ) ;
175+ println ! (
176+ "{}" ,
177+ self . formatter
178+ . format_success( "Config set (not saved - specify --config to persist)" )
179+ ) ;
152180 }
153181
154182 Ok ( EXIT_SUCCESS )
@@ -160,16 +188,26 @@ impl CommandHandler {
160188 let config = match profile {
161189 "development" => defaults:: development_profile ( ) ,
162190 "production" => defaults:: production_profile ( ) ,
163- _ => return Err ( CliError :: UsageError (
164- "profile must be 'development' or 'production'" . to_string ( ) ,
165- ) ) ,
191+ _ => {
192+ return Err ( CliError :: UsageError (
193+ "profile must be 'development' or 'production'" . to_string ( ) ,
194+ ) )
195+ } ,
166196 } ;
167197
168198 if let Some ( path) = & self . global_opts . config {
169199 ConfigLoader :: save ( & config, path) ?;
170- println ! ( "{}" , self . formatter. format_success( & format!( "Initialized config with '{}' profile" , profile) ) ) ;
200+ println ! (
201+ "{}" ,
202+ self . formatter
203+ . format_success( & format!( "Initialized config with '{}' profile" , profile) )
204+ ) ;
171205 } else {
172- println ! ( "{}" , self . formatter. format_success( "Config initialized (specify --config to save)" ) ) ;
206+ println ! (
207+ "{}" ,
208+ self . formatter
209+ . format_success( "Config initialized (specify --config to save)" )
210+ ) ;
173211 }
174212
175213 Ok ( EXIT_SUCCESS )
@@ -185,9 +223,16 @@ impl CommandHandler {
185223 let config = Default :: default ( ) ;
186224 if let Some ( path) = & self . global_opts . config {
187225 ConfigLoader :: save ( & config, path) ?;
188- println ! ( "{}" , self . formatter. format_success( "Config reset to defaults" ) ) ;
226+ println ! (
227+ "{}" ,
228+ self . formatter. format_success( "Config reset to defaults" )
229+ ) ;
189230 } else {
190- println ! ( "{}" , self . formatter. format_success( "Config would be reset (specify --config to persist)" ) ) ;
231+ println ! (
232+ "{}" ,
233+ self . formatter
234+ . format_success( "Config would be reset (specify --config to persist)" )
235+ ) ;
191236 }
192237 Ok ( EXIT_SUCCESS )
193238 }
@@ -198,37 +243,72 @@ impl CommandHandler {
198243 }
199244
200245 async fn handle_debug_bus_latency ( & self , num_messages : u32 ) -> CliResult < i32 > {
201- println ! ( "{}" , self . formatter. format_success( & format!( "Would test bus latency with {} messages (not yet implemented)" , num_messages) ) ) ;
246+ println ! (
247+ "{}" ,
248+ self . formatter. format_success( & format!(
249+ "Would test bus latency with {} messages (not yet implemented)" ,
250+ num_messages
251+ ) )
252+ ) ;
202253 Ok ( EXIT_SUCCESS )
203254 }
204255
205256 async fn handle_debug_memory_stats ( & self ) -> CliResult < i32 > {
206- println ! ( "{}" , self . formatter. format_success( "Memory stats (not yet implemented)" ) ) ;
257+ println ! (
258+ "{}" ,
259+ self . formatter
260+ . format_success( "Memory stats (not yet implemented)" )
261+ ) ;
207262 Ok ( EXIT_SUCCESS )
208263 }
209264
210265 async fn handle_debug_adapter_test ( & self , adapter : & str ) -> CliResult < i32 > {
211- println ! ( "{}" , self . formatter. format_success( & format!( "Testing adapter: {} (not yet implemented)" , adapter) ) ) ;
266+ println ! (
267+ "{}" ,
268+ self . formatter. format_success( & format!(
269+ "Testing adapter: {} (not yet implemented)" ,
270+ adapter
271+ ) )
272+ ) ;
212273 Ok ( EXIT_SUCCESS )
213274 }
214275
215276 async fn handle_debug_trace_flow ( & self , task_id : & str ) -> CliResult < i32 > {
216- println ! ( "{}" , self . formatter. format_success( & format!( "Tracing task: {} (not yet implemented)" , task_id) ) ) ;
277+ println ! (
278+ "{}" ,
279+ self . formatter
280+ . format_success( & format!( "Tracing task: {} (not yet implemented)" , task_id) )
281+ ) ;
217282 Ok ( EXIT_SUCCESS )
218283 }
219284
220285 async fn handle_debug_profile ( & self , duration : u32 ) -> CliResult < i32 > {
221- println ! ( "{}" , self . formatter. format_success( & format!( "Profiling for {} seconds (not yet implemented)" , duration) ) ) ;
286+ println ! (
287+ "{}" ,
288+ self . formatter. format_success( & format!(
289+ "Profiling for {} seconds (not yet implemented)" ,
290+ duration
291+ ) )
292+ ) ;
222293 Ok ( EXIT_SUCCESS )
223294 }
224295
225296 async fn handle_debug_validate_intent ( & self , text : & str ) -> CliResult < i32 > {
226- println ! ( "{}" , self . formatter. format_success( & format!( "Validating intent: {} (not yet implemented)" , text) ) ) ;
297+ println ! (
298+ "{}" ,
299+ self . formatter. format_success( & format!(
300+ "Validating intent: {} (not yet implemented)" ,
301+ text
302+ ) )
303+ ) ;
227304 Ok ( EXIT_SUCCESS )
228305 }
229306
230307 async fn handle_repl ( & self ) -> CliResult < i32 > {
231- println ! ( "{}" , self . formatter. format_success( "Starting REPL mode (M1.4.3)" ) ) ;
308+ println ! (
309+ "{}" ,
310+ self . formatter. format_success( "Starting REPL mode (M1.4.3)" )
311+ ) ;
232312 Ok ( EXIT_SUCCESS )
233313 }
234314
0 commit comments