File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,12 +96,28 @@ pub async fn run_login_status(_config_overrides: CliConfigOverrides) -> ! {
9696}
9797
9898/// Run logout.
99- pub async fn run_logout ( _config_overrides : CliConfigOverrides ) -> ! {
99+ pub async fn run_logout ( _config_overrides : CliConfigOverrides , skip_confirmation : bool ) -> ! {
100100 let Some ( cortex_home) = get_cortex_home ( ) else {
101101 eprintln ! ( "Error: Could not determine home directory" ) ;
102102 std:: process:: exit ( 1 ) ;
103103 } ;
104104
105+ // Prompt for confirmation unless --yes flag is provided
106+ if !skip_confirmation {
107+ eprintln ! (
108+ "Are you sure you want to log out? This will remove your stored credentials. [y/N]"
109+ ) ;
110+ let mut input = String :: new ( ) ;
111+ if std:: io:: stdin ( ) . read_line ( & mut input) . is_err ( ) {
112+ eprintln ! ( "Error reading input" ) ;
113+ std:: process:: exit ( 1 ) ;
114+ }
115+ if !input. trim ( ) . eq_ignore_ascii_case ( "y" ) && !input. trim ( ) . eq_ignore_ascii_case ( "yes" ) {
116+ eprintln ! ( "Logout cancelled." ) ;
117+ std:: process:: exit ( 0 ) ;
118+ }
119+ }
120+
105121 match logout ( & cortex_home, CredentialsStoreMode :: default ( ) ) {
106122 Ok ( true ) => {
107123 eprintln ! ( "Successfully logged out" ) ;
Original file line number Diff line number Diff line change @@ -277,6 +277,10 @@ enum LoginSubcommand {
277277struct LogoutCommand {
278278 #[ clap( skip) ]
279279 config_overrides : CliConfigOverrides ,
280+
281+ /// Skip confirmation prompt
282+ #[ arg( long, short = 'y' ) ]
283+ yes : bool ,
280284}
281285
282286/// Completion command.
@@ -473,7 +477,7 @@ async fn main() -> Result<()> {
473477 Ok ( ( ) )
474478 }
475479 Some ( Commands :: Logout ( logout_cli) ) => {
476- run_logout ( logout_cli. config_overrides ) . await ;
480+ run_logout ( logout_cli. config_overrides , logout_cli . yes ) . await ;
477481 Ok ( ( ) )
478482 }
479483 Some ( Commands :: Mcp ( mcp_cli) ) => mcp_cli. run ( ) . await ,
You can’t perform that action at this time.
0 commit comments