Add git implementation of task manager
Change-Id: I1e0925e54fa167af9459eceea7a2cae082bc4504
diff --git a/server/tm/git_tm/example.go b/server/tm/git_tm/example.go
new file mode 100644
index 0000000..39541fa
--- /dev/null
+++ b/server/tm/git_tm/example.go
@@ -0,0 +1,114 @@
+package git_tm
+
+import (
+ "context"
+ "fmt"
+ "log"
+ "time"
+
+ "github.com/iomodo/staff/git"
+ "github.com/iomodo/staff/tm"
+)
+
+// Example demonstrates how to use the GitTaskManager
+func Example() {
+ // Initialize git interface
+ gitInterface := git.DefaultGit("./tasks-repo")
+
+ // Create task manager
+ taskManager := NewGitTaskManager(gitInterface, "./tasks-repo")
+
+ // Create a new task
+ ctx := context.Background()
+ dueDate := time.Now().AddDate(0, 0, 7) // Due in 7 days
+
+ createReq := &tm.TaskCreateRequest{
+ Title: "Implement user authentication",
+ Description: "Add login/logout functionality with JWT tokens",
+ OwnerID: "john.doe",
+ Priority: tm.PriorityHigh,
+ DueDate: &dueDate,
+ }
+
+ task, err := taskManager.CreateTask(ctx, createReq)
+ if err != nil {
+ log.Fatalf("Failed to create task: %v", err)
+ }
+
+ fmt.Printf("Created task: %s\n", task.ID)
+
+ // Get the task
+ retrievedTask, err := taskManager.GetTask(ctx, task.ID)
+ if err != nil {
+ log.Fatalf("Failed to get task: %v", err)
+ }
+
+ fmt.Printf("Retrieved task: %s - %s\n", retrievedTask.ID, retrievedTask.Title)
+
+ // Start the task
+ startedTask, err := taskManager.StartTask(ctx, task.ID)
+ if err != nil {
+ log.Fatalf("Failed to start task: %v", err)
+ }
+
+ fmt.Printf("Started task: %s (status: %s)\n", startedTask.ID, startedTask.Status)
+
+ // List all tasks
+ taskList, err := taskManager.ListTasks(ctx, nil, 0, 10)
+ if err != nil {
+ log.Fatalf("Failed to list tasks: %v", err)
+ }
+
+ fmt.Printf("Total tasks: %d\n", taskList.TotalCount)
+ for _, t := range taskList.Tasks {
+ fmt.Printf("- %s: %s (%s)\n", t.ID, t.Title, t.Status)
+ }
+
+ // Complete the task
+ completedTask, err := taskManager.CompleteTask(ctx, task.ID)
+ if err != nil {
+ log.Fatalf("Failed to complete task: %v", err)
+ }
+
+ fmt.Printf("Completed task: %s (completed at: %s)\n",
+ completedTask.ID, completedTask.CompletedAt.Format(time.RFC3339))
+}
+
+// ExampleTaskFile shows the format of a task file
+func ExampleTaskFile() {
+ fmt.Print(`Example task file (tasks/task-1704067200-abc123.md):
+
+---
+id: task-1704067200-abc123
+title: Implement user authentication
+description: Add login/logout functionality with JWT tokens
+owner_id: john.doe
+owner_name: John Doe
+status: in_progress
+priority: high
+created_at: 2024-01-01T10:00:00Z
+updated_at: 2024-01-01T15:30:00Z
+due_date: 2024-01-08T17:00:00Z
+completed_at: null
+archived_at: null
+---
+
+# Task Description
+
+Add login/logout functionality with JWT tokens for the web application.
+
+## Requirements
+
+- User registration and login forms
+- JWT token generation and validation
+- Password hashing with bcrypt
+- Session management
+- Logout functionality
+
+## Notes
+
+- Consider using bcrypt for password hashing
+- Implement refresh token mechanism
+- Add rate limiting for login attempts
+`)
+}