(deps commandDeps)
| 365 | } |
| 366 | |
| 367 | func newSessionRepairCommand(deps commandDeps) *cobra.Command { |
| 368 | var ( |
| 369 | dryRun bool |
| 370 | force bool |
| 371 | ) |
| 372 | |
| 373 | cmd := &cobra.Command{ |
| 374 | Use: "repair <id>", |
| 375 | Short: "Inspect and repair an interrupted session transcript", |
| 376 | Example: ` # Report the repair actions without writing new events |
| 377 | agh session repair sess_1234 --dry-run |
| 378 | |
| 379 | # Force repair for a stopped session whose stop reason is not crash or error |
| 380 | agh session repair sess_1234 --force`, |
| 381 | Args: exactOneNonBlankArg(), |
| 382 | RunE: func(cmd *cobra.Command, args []string) error { |
| 383 | client, err := clientFromDeps(deps) |
| 384 | if err != nil { |
| 385 | return err |
| 386 | } |
| 387 | |
| 388 | result, err := client.RepairSession(cmd.Context(), args[0], SessionRepairQuery{ |
| 389 | DryRun: dryRun, |
| 390 | Force: force, |
| 391 | }) |
| 392 | if err != nil { |
| 393 | return err |
| 394 | } |
| 395 | return writeCommandOutput(cmd, sessionRepairBundle(result)) |
| 396 | }, |
| 397 | } |
| 398 | cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Report planned repairs without persisting events") |
| 399 | cmd.Flags().BoolVar(&force, "force", false, "Allow repair for stopped non-crash sessions") |
| 400 | return cmd |
| 401 | } |
| 402 | |
| 403 | func newSessionApproveCommand(deps commandDeps) *cobra.Command { |
| 404 | var request SessionApprovalRequest |
no test coverage detected