@@ -374,9 +374,21 @@ impl Cli {
374374
375375 Self :: execute_chat ( "chat" , Some ( args) , true ) . await
376376 } ,
377- CliRootCommands :: Mcp { args } => Self :: execute_chat ( "mcp" , Some ( args) , false ) . await ,
377+ CliRootCommands :: Mcp { args } => {
378+ if args. iter ( ) . any ( |arg| [ "--help" , "-h" ] . contains ( & arg. as_str ( ) ) ) {
379+ return Self :: execute_chat ( "mcp" , Some ( args) , false ) . await ;
380+ }
381+
382+ Self :: execute_chat ( "mcp" , Some ( args) , true ) . await
383+ } ,
378384 CliRootCommands :: Inline ( subcommand) => subcommand. execute ( & cli_context) . await ,
379- CliRootCommands :: Agent { args } => Self :: execute_chat ( "agent" , Some ( args) , false ) . await ,
385+ CliRootCommands :: Agent { args } => {
386+ if args. iter ( ) . any ( |arg| [ "--help" , "-h" ] . contains ( & arg. as_str ( ) ) ) {
387+ return Self :: execute_chat ( "agent" , Some ( args) , false ) . await ;
388+ }
389+
390+ Self :: execute_chat ( "agent" , Some ( args) , true ) . await
391+ } ,
380392 } ,
381393 // Root command
382394 None => Self :: execute_chat ( "chat" , None , true ) . await ,
@@ -385,12 +397,19 @@ impl Cli {
385397
386398 pub async fn execute_chat ( subcmd : & str , args : Option < Vec < String > > , enforce_login : bool ) -> Result < ExitCode > {
387399 if enforce_login && !is_logged_in_check ( ) . await {
388- let options = [ "Yes" , "No" ] ;
389- match crate :: util:: choose ( " You are not logged in. Login now?" , & options) ? {
390- Some ( 0 ) => { } ,
391- _ => bail ! ( "Login is required to use chat" ) ,
400+ if subcmd == "chat" {
401+ let options = [ "Yes" , "No" ] ;
402+ match crate :: util:: choose ( " You are not logged in. Login now?" , & options) ? {
403+ Some ( 0 ) => { } ,
404+ _ => bail ! ( "Login is required to use chat" ) ,
405+ }
406+ crate :: cli:: user:: login_interactive ( Default :: default ( ) ) . await ?;
407+ } else {
408+ bail ! (
409+ "You are not logged in, please log in with {}" ,
410+ format!( "{CLI_BINARY_NAME} login" , ) . bold( )
411+ ) ;
392412 }
393- crate :: cli:: user:: login_interactive ( Default :: default ( ) ) . await ?;
394413 }
395414
396415 // Save credentials from the macOS keychain to sqlite.
0 commit comments