(deps commandDeps)
| 48 | } |
| 49 | |
| 50 | func newWorkspaceAddCommand(deps commandDeps) *cobra.Command { |
| 51 | var ( |
| 52 | name string |
| 53 | addDirs []string |
| 54 | defaultAgent string |
| 55 | sandboxRef string |
| 56 | ) |
| 57 | |
| 58 | cmd := &cobra.Command{ |
| 59 | Use: "add <path>", |
| 60 | Short: "Register a workspace", |
| 61 | Example: ` # Register a workspace with a stable name |
| 62 | agh workspace add "$PWD" --name checkout-api |
| 63 | |
| 64 | # Include an additional directory and set a workspace default agent |
| 65 | agh workspace add "$PWD" --name platform --add-dir "$PWD/docs" --default-agent architect`, |
| 66 | Args: exactOneNonBlankArg(), |
| 67 | RunE: func(cmd *cobra.Command, args []string) error { |
| 68 | client, err := clientFromDeps(deps) |
| 69 | if err != nil { |
| 70 | return err |
| 71 | } |
| 72 | |
| 73 | workspace, err := client.CreateWorkspace(cmd.Context(), WorkspaceCreateRequest{ |
| 74 | RootDir: strings.TrimSpace(args[0]), |
| 75 | Name: strings.TrimSpace(name), |
| 76 | AddDirs: trimmedUniqueStrings(addDirs), |
| 77 | DefaultAgent: strings.TrimSpace(defaultAgent), |
| 78 | SandboxRef: strings.TrimSpace(sandboxRef), |
| 79 | }) |
| 80 | if err != nil { |
| 81 | return err |
| 82 | } |
| 83 | |
| 84 | return writeCommandOutput(cmd, workspaceRecordBundle(workspace)) |
| 85 | }, |
| 86 | } |
| 87 | cmd.Flags().StringVar(&name, automationNameKey, "", "Optional workspace name") |
| 88 | cmd.Flags(). |
| 89 | StringArrayVar(&addDirs, "add-dir", nil, "Additional directory to include (repeatable)") |
| 90 | cmd.Flags(). |
| 91 | StringVar(&defaultAgent, "default-agent", "", "Default agent override for this workspace") |
| 92 | cmd.Flags(). |
| 93 | StringVar(&sandboxRef, "sandbox", "", "Sandbox profile override for this workspace") |
| 94 | return cmd |
| 95 | } |
| 96 | |
| 97 | func newWorkspaceListCommand(deps commandDeps) *cobra.Command { |
| 98 | return &cobra.Command{ |
no test coverage detected