@@ -5,8 +5,10 @@ use forge_api::{API, Update};
55use forge_tracker:: VERSION ;
66use update_informer:: { Check , Version , registry} ;
77
8- /// Runs the official installation script to update Forge, failing silently
9- async fn execute_update_command ( api : Arc < impl API > ) {
8+ /// Runs the official installation script to update Forge, failing silently.
9+ /// When `auto_update` is true, exits immediately after a successful update
10+ /// without prompting the user.
11+ async fn execute_update_command ( api : Arc < impl API > , auto_update : bool ) {
1012 // Spawn a new task that won't block the main application
1113 let output = api
1214 . execute_shell_command_raw ( "curl -fsSL https://forgecode.dev/cli | sh" )
@@ -20,12 +22,17 @@ async fn execute_update_command(api: Arc<impl API>) {
2022 }
2123 Ok ( output) => {
2224 if output. success ( ) {
23- let answer = forge_select:: ForgeSelect :: confirm (
24- "You need to close forge to complete update. Do you want to close it now?" ,
25- )
26- . with_default ( true )
27- . prompt ( ) ;
28- if answer. unwrap_or_default ( ) . unwrap_or_default ( ) {
25+ let should_exit = if auto_update {
26+ true
27+ } else {
28+ let answer = forge_select:: ForgeSelect :: confirm (
29+ "You need to close forge to complete update. Do you want to close it now?" ,
30+ )
31+ . with_default ( true )
32+ . prompt ( ) ;
33+ answer. unwrap_or_default ( ) . unwrap_or_default ( )
34+ } ;
35+ if should_exit {
2936 std:: process:: exit ( 0 ) ;
3037 }
3138 } else {
@@ -75,7 +82,7 @@ pub async fn on_update(api: Arc<impl API>, update: Option<&Update>) {
7582 if let Some ( version) = informer. check_version ( ) . ok ( ) . flatten ( )
7683 && ( auto_update || confirm_update ( version) . await )
7784 {
78- execute_update_command ( api) . await ;
85+ execute_update_command ( api, auto_update ) . await ;
7986 }
8087}
8188
0 commit comments