File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -133,17 +133,23 @@ impl RootSubcommand {
133133 matches ! ( self , Self :: Chat ( _) | Self :: Login ( _) | Self :: Profile | Self :: Issue ( _) )
134134 }
135135
136- pub fn requires_auth ( & self ) -> bool {
137- matches ! ( self , Self :: Chat ( _) | Self :: Profile )
138- }
139-
140136 pub async fn execute ( self , os : & mut Os ) -> Result < ExitCode > {
141137 // Check for auth on subcommands that require it.
142- if self . requires_auth ( ) && !is_logged_in ( & mut os. database ) . await {
143- bail ! (
144- "You are not logged in, please log in with {}" ,
145- StyledText :: command( & format!( "{CLI_BINARY_NAME} login" ) )
146- ) ;
138+ if !is_logged_in ( & mut os. database ) . await {
139+ if matches ! ( self , Self :: Chat ( _) ) {
140+ let options = [ "Yes" , "No" ] ;
141+ match crate :: util:: choose ( " You are not logged in. Login now?" , & options) ? {
142+ Some ( 0 ) => { } ,
143+ _ => bail ! ( "Login is required to use chat" ) ,
144+ }
145+
146+ LoginArgs :: default ( ) . execute ( os) . await ?;
147+ } else if matches ! ( self , Self :: Profile ) {
148+ bail ! (
149+ "You are not logged in, please log in with {}" ,
150+ StyledText :: command( & format!( "{CLI_BINARY_NAME} login" ) )
151+ ) ;
152+ }
147153 }
148154
149155 // Daily heartbeat check
You can’t perform that action at this time.
0 commit comments