Execute a local command.
(
self,
command: LocalCommand,
args: str,
)
| 166 | return result |
| 167 | |
| 168 | async def _execute_local( |
| 169 | self, |
| 170 | command: LocalCommand, |
| 171 | args: str, |
| 172 | ) -> CommandResult: |
| 173 | """Execute a local command.""" |
| 174 | try: |
| 175 | local_result = await command.call(args, self.context) |
| 176 | |
| 177 | if local_result.type == "skip": |
| 178 | return CommandResult.skip(command.name) |
| 179 | |
| 180 | display_text = local_result.display_text or local_result.value |
| 181 | if local_result.type == "compact": |
| 182 | # C3b: preserve the compact result type so UI surfaces can |
| 183 | # render a boundary row (TS CompactBoundaryMessage) instead |
| 184 | # of a plain system line. text still carries the |
| 185 | # user_display_message for surfaces that don't special-case. |
| 186 | return CommandResult( |
| 187 | success=True, |
| 188 | command_name=command.name, |
| 189 | result_type="compact", |
| 190 | text=display_text, |
| 191 | display="system", |
| 192 | ) |
| 193 | return CommandResult.success_text( |
| 194 | command.name, |
| 195 | display_text, |
| 196 | ) |
| 197 | except Exception as e: |
| 198 | return CommandResult.error( |
| 199 | command.name, |
| 200 | str(e), |
| 201 | ) |
| 202 | |
| 203 | async def _execute_prompt( |
| 204 | self, |
no test coverage detected