@@ -55,7 +55,7 @@ pub async fn handle_args(args: impl Iterator<Item = OsString>) -> Result<()> {
5555 return Ok ( ( ) ) ;
5656 }
5757
58- let args: Args = clap:: Parser :: parse_from ( args) ;
58+ let mut args: Args = clap:: Parser :: parse_from ( args) ;
5959 let app_settings = AppSettings :: load_from_default_path_creating ( ) ?;
6060
6161 if args. trace > 0 {
@@ -67,7 +67,7 @@ pub async fn handle_args(args: impl Iterator<Item = OsString>) -> Result<()> {
6767 let start = std:: time:: Instant :: now ( ) ;
6868
6969 // If no subcommand is provided but we have source and target, default to rub
70- match & args. cmd {
70+ match args. cmd . take ( ) {
7171 None if args. source . is_some ( ) && args. target . is_some ( ) => {
7272 // Default to rub when two arguments are provided without a subcommand
7373 let source = args
@@ -92,19 +92,19 @@ pub async fn handle_args(args: impl Iterator<Item = OsString>) -> Result<()> {
9292 print_grouped_help ( ) ;
9393 Ok ( ( ) )
9494 }
95- Some ( cmd) => match_subcommand ( cmd, & args, app_settings, start) . await ,
95+ Some ( cmd) => match_subcommand ( cmd, args, app_settings, start) . await ,
9696 }
9797}
9898
9999async fn match_subcommand (
100- cmd : & Subcommands ,
101- args : & Args ,
100+ cmd : Subcommands ,
101+ args : Args ,
102102 app_settings : AppSettings ,
103103 start : std:: time:: Instant ,
104104) -> Result < ( ) > {
105105 match cmd {
106106 Subcommands :: Mcp { internal } => {
107- if * internal {
107+ if internal {
108108 mcp_internal:: start ( app_settings) . await
109109 } else {
110110 mcp:: start ( app_settings) . await
@@ -115,9 +115,8 @@ async fn match_subcommand(
115115 description,
116116 handler,
117117 } ) => {
118- let handler = * handler;
119118 let project = get_or_init_project ( & args. current_dir ) ?;
120- command:: handle_changes ( & project, args. json , handler, description)
119+ command:: handle_changes ( & project, args. json , handler, & description)
121120 }
122121 None => {
123122 let project = get_or_init_project ( & args. current_dir ) ?;
@@ -128,8 +127,8 @@ async fn match_subcommand(
128127 command_name,
129128 props,
130129 } => {
131- let event = & mut Event :: new ( ( * command_name) . into ( ) ) ;
132- if let Ok ( props) = Props :: from_json_string ( props) {
130+ let event = & mut Event :: new ( command_name. into ( ) ) ;
131+ if let Ok ( props) = Props :: from_json_string ( & props) {
133132 props. update_event ( event) ;
134133 }
135134 Metrics :: capture_blocking ( & app_settings, event. clone ( ) ) . await ;
@@ -170,7 +169,7 @@ async fn match_subcommand(
170169 Ok ( ( ) )
171170 }
172171 cursor:: Subcommands :: Stop { nightly } => {
173- let result = but_cursor:: handle_stop ( * nightly) . await ;
172+ let result = but_cursor:: handle_stop ( nightly) . await ;
174173 let p = props ( start, & result) ;
175174 println ! ( "{}" , serde_json:: to_string( & result?) ?) ;
176175 metrics_if_configured ( app_settings, CommandName :: CursorStop , p) . ok ( ) ;
@@ -179,27 +178,23 @@ async fn match_subcommand(
179178 } ,
180179 Subcommands :: Base ( base:: Platform { cmd } ) => {
181180 let project = get_or_init_project ( & args. current_dir ) ?;
181+ let metrics_cmd = match cmd {
182+ base:: Subcommands :: Check => CommandName :: BaseCheck ,
183+ base:: Subcommands :: Update => CommandName :: BaseUpdate ,
184+ } ;
182185 let result = base:: handle ( cmd, & project, args. json ) ;
183- metrics_if_configured (
184- app_settings,
185- match cmd {
186- base:: Subcommands :: Check => CommandName :: BaseCheck ,
187- base:: Subcommands :: Update => CommandName :: BaseUpdate ,
188- } ,
189- props ( start, & result) ,
190- )
191- . ok ( ) ;
186+ metrics_if_configured ( app_settings, metrics_cmd, props ( start, & result) ) . ok ( ) ;
192187 Ok ( ( ) )
193188 }
194189 Subcommands :: Branch ( branch:: Platform { cmd } ) => {
195190 let project = get_or_init_project ( & args. current_dir ) ?;
196- let result = branch:: handle ( cmd, & project, args. json ) . await ;
197191 let metrics_command = match cmd {
198192 None | Some ( branch:: Subcommands :: List { .. } ) => CommandName :: BranchList ,
199193 Some ( branch:: Subcommands :: New { .. } ) => CommandName :: BranchNew ,
200194 Some ( branch:: Subcommands :: Delete { .. } ) => CommandName :: BranchDelete ,
201195 Some ( branch:: Subcommands :: Unapply { .. } ) => CommandName :: BranchUnapply ,
202196 } ;
197+ let result = branch:: handle ( cmd, & project, args. json ) . await ;
203198 metrics_if_configured ( app_settings, metrics_command, props ( start, & result) ) . ok ( ) ;
204199 result
205200 }
@@ -222,21 +217,20 @@ async fn match_subcommand(
222217 review,
223218 } => {
224219 let project = get_or_init_project ( & args. current_dir ) ?;
225- let result =
226- status:: worktree ( & project, args. json , * show_files, * verbose, * review) . await ;
220+ let result = status:: worktree ( & project, args. json , show_files, verbose, review) . await ;
227221 metrics_if_configured ( app_settings, CommandName :: Status , props ( start, & result) ) . ok ( ) ;
228222 result
229223 }
230224 Subcommands :: Stf { verbose, review } => {
231225 let project = get_or_init_project ( & args. current_dir ) ?;
232- let result = status:: worktree ( & project, args. json , true , * verbose, * review) . await ;
226+ let result = status:: worktree ( & project, args. json , true , verbose, review) . await ;
233227 metrics_if_configured ( app_settings, CommandName :: Stf , props ( start, & result) ) . ok ( ) ;
234228 result
235229 }
236230 Subcommands :: Rub { source, target } => {
237231 let project = get_or_init_project ( & args. current_dir ) ?;
238232 let result =
239- rub:: handle ( & project, args. json , source, target) . context ( "Rubbed the wrong way." ) ;
233+ rub:: handle ( & project, args. json , & source, & target) . context ( "Rubbed the wrong way." ) ;
240234 if let Err ( e) = & result {
241235 eprintln ! ( "{} {}" , e, e. root_cause( ) ) ;
242236 }
@@ -245,7 +239,7 @@ async fn match_subcommand(
245239 }
246240 Subcommands :: Mark { target, delete } => {
247241 let project = get_or_init_project ( & args. current_dir ) ?;
248- let result = mark:: handle ( & project, args. json , target, * delete)
242+ let result = mark:: handle ( & project, args. json , & target, delete)
249243 . context ( "Can't mark this. Taaaa-na-na-na. Can't mark this." ) ;
250244 if let Err ( e) = & result {
251245 eprintln ! ( "{} {}" , e, e. root_cause( ) ) ;
@@ -280,8 +274,8 @@ async fn match_subcommand(
280274 args. json ,
281275 message. as_deref ( ) ,
282276 branch. as_deref ( ) ,
283- * only,
284- * create,
277+ only,
278+ create,
285279 ) ;
286280 metrics_if_configured ( app_settings, CommandName :: Commit , props ( start, & result) ) . ok ( ) ;
287281 result
@@ -294,13 +288,13 @@ async fn match_subcommand(
294288 }
295289 Subcommands :: New { target } => {
296290 let project = get_or_init_project ( & args. current_dir ) ?;
297- let result = commit:: insert_blank_commit ( & project, args. json , target) ;
291+ let result = commit:: insert_blank_commit ( & project, args. json , & target) ;
298292 metrics_if_configured ( app_settings, CommandName :: New , props ( start, & result) ) . ok ( ) ;
299293 result
300294 }
301295 Subcommands :: Describe { target } => {
302296 let project = get_or_init_project ( & args. current_dir ) ?;
303- let result = describe:: describe_target ( & project, args. json , target) ;
297+ let result = describe:: describe_target ( & project, args. json , & target) ;
304298 metrics_if_configured ( app_settings, CommandName :: Describe , props ( start, & result) ) . ok ( ) ;
305299 result
306300 }
@@ -312,7 +306,7 @@ async fn match_subcommand(
312306 }
313307 Subcommands :: Restore { oplog_sha, force } => {
314308 let project = get_or_init_project ( & args. current_dir ) ?;
315- let result = oplog:: restore_to_oplog ( & project, args. json , oplog_sha, * force) ;
309+ let result = oplog:: restore_to_oplog ( & project, args. json , & oplog_sha, force) ;
316310 metrics_if_configured ( app_settings, CommandName :: Restore , props ( start, & result) ) . ok ( ) ;
317311 result
318312 }
@@ -334,15 +328,15 @@ async fn match_subcommand(
334328 metrics_if_configured ( app_settings, CommandName :: Snapshot , props ( start, & result) ) . ok ( ) ;
335329 result
336330 }
337- Subcommands :: Init { repo } => init:: repo ( & args. current_dir , args. json , * repo)
331+ Subcommands :: Init { repo } => init:: repo ( & args. current_dir , args. json , repo)
338332 . context ( "Failed to initialize GitButler project." ) ,
339333 Subcommands :: Forge ( forge:: integration:: Platform { cmd } ) => {
340- let result = forge:: integration:: handle ( cmd) . await ;
341334 let metrics_cmd = match cmd {
342335 forge:: integration:: Subcommands :: Auth => CommandName :: ForgeAuth ,
343336 forge:: integration:: Subcommands :: ListUsers => CommandName :: ForgeListUsers ,
344337 forge:: integration:: Subcommands :: Forget { .. } => CommandName :: ForgeForget ,
345338 } ;
339+ let result = forge:: integration:: handle ( cmd) . await ;
346340 metrics_if_configured ( app_settings, metrics_cmd, props ( start, & result) ) . ok ( ) ;
347341 result
348342 }
@@ -358,10 +352,10 @@ async fn match_subcommand(
358352 let result = forge:: review:: publish_reviews (
359353 & project,
360354 branch,
361- * skip_force_push_protection,
362- * with_force,
363- * run_hooks,
364- * default,
355+ skip_force_push_protection,
356+ with_force,
357+ run_hooks,
358+ default,
365359 args. json ,
366360 )
367361 . await
@@ -375,7 +369,7 @@ async fn match_subcommand(
375369 result
376370 }
377371 } ,
378- Subcommands :: Completions { shell } => completions:: generate_completions ( * shell) ,
372+ Subcommands :: Completions { shell } => completions:: generate_completions ( shell) ,
379373 }
380374}
381375
0 commit comments