(self, os: &mut Os)
| 141 | } |
| 142 | |
| 143 | pub async fn execute(self, os: &mut Os) -> Result<ExitCode> { |
| 144 | // Check for auth on subcommands that require it. |
| 145 | if self.requires_auth() && !crate::auth::is_logged_in(&mut os.database).await { |
| 146 | bail!( |
| 147 | "You are not logged in, please log in with {}", |
| 148 | StyledText::command(&format!("{CLI_BINARY_NAME} login")) |
| 149 | ); |
| 150 | } |
| 151 | |
| 152 | // Daily heartbeat check |
| 153 | if os.database.should_send_heartbeat() && os.telemetry.send_daily_heartbeat().is_ok() { |
| 154 | os.database.record_heartbeat_sent().ok(); |
| 155 | } |
| 156 | |
| 157 | // Send executed telemetry. |
| 158 | if self.valid_for_telemetry() { |
| 159 | os.telemetry |
| 160 | .send_cli_subcommand_executed(&os.database, &self) |
| 161 | .await |
| 162 | .ok(); |
| 163 | } |
| 164 | |
| 165 | match self { |
| 166 | Self::Agent(args) => args.execute(os).await, |
| 167 | Self::Diagnostic(args) => args.execute(os).await, |
| 168 | Self::Login(args) => args.execute(os).await, |
| 169 | Self::Logout => user::logout(os).await, |
| 170 | Self::Whoami(args) => args.execute(os).await, |
| 171 | Self::Profile => user::profile(os).await, |
| 172 | Self::Settings(settings_args) => settings_args.execute(os).await, |
| 173 | Self::Issue(args) => args.execute(os).await, |
| 174 | Self::Version { changelog } => Cli::print_version(changelog), |
| 175 | Self::Chat(args) => args.execute(os).await, |
| 176 | Self::Mcp(args) => args.execute(os, &mut std::io::stderr()).await, |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | impl Default for RootSubcommand { |
no test coverage detected