| user | 5a7d60d | 2025-07-27 21:22:04 +0400 | [diff] [blame] | 1 | package commands |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "github.com/spf13/cobra" |
| 7 | ) |
| 8 | |
| 9 | var assignTaskCmd = &cobra.Command{ |
| 10 | Use: "assign-task [task-id] [agent-name]", |
| 11 | Short: "Assign a task to an agent", |
| 12 | Long: `Assign an existing task to a specific agent. |
| 13 | |
| 14 | Examples: |
| 15 | staff assign-task task-1234567890-abcd1234 backend-engineer |
| 16 | staff assign-task task-1234567890-abcd1234 frontend-engineer`, |
| 17 | Args: cobra.ExactArgs(2), |
| 18 | RunE: runAssignTask, |
| 19 | } |
| 20 | |
| 21 | func runAssignTask(cmd *cobra.Command, args []string) error { |
| 22 | taskID := args[0] |
| 23 | agentName := args[1] |
| 24 | |
| 25 | // Get the task |
| 26 | task, err := taskManager.GetTask(taskID) |
| 27 | if err != nil { |
| 28 | return fmt.Errorf("failed to get task: %w", err) |
| 29 | } |
| 30 | |
| 31 | // Assign the task |
| 32 | task.Assignee = agentName |
| 33 | if err := taskManager.UpdateTask(task); err != nil { |
| 34 | return fmt.Errorf("failed to assign task: %w", err) |
| 35 | } |
| 36 | |
| 37 | fmt.Printf("Task %s assigned to %s successfully!\n", taskID, agentName) |
| 38 | fmt.Printf("Title: %s\n", task.Title) |
| 39 | fmt.Printf("Priority: %s\n", task.Priority) |
| 40 | fmt.Printf("Status: %s\n", task.Status) |
| 41 | |
| 42 | return nil |
| iomodo | 50598c6 | 2025-07-27 22:06:32 +0400 | [diff] [blame] | 43 | } |