6e6c3dbea4
Phase 6: Display and Basic Commands - Add display.go with colored formatting for tasks, projects, tags - Implement cmd/root.go with Cobra command structure - Implement cmd/list.go for listing and filtering tasks - Implement cmd/add.go with support for regular and recurring tasks - Implement cmd/done.go with bulk completion and confirmation Phase 7: Advanced Commands - Implement cmd/modify.go for updating task attributes - Implement cmd/delete.go with soft delete confirmation - Implement cmd/start.go and cmd/stop.go for task timing - Implement cmd/count.go for counting filtered tasks - Implement cmd/projects.go and cmd/tags.go for aggregation Phase 8: Integration and Polish - Update main.go to use CLI commands - Add colored output with fatih/color - Format task lists with proper alignment - Highlight overdue tasks in red, upcoming in yellow - Test end-to-end workflow: add, list, done, recurring tasks - Verify recurrence spawning works correctly All CLI commands functional and tested!
52 lines
904 B
Go
52 lines
904 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.jnss.me/joakim/opal/internal/engine"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var deleteCmd = &cobra.Command{
|
|
Use: "delete [filter...]",
|
|
Short: "Delete tasks",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if err := deleteTasks(args); err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
},
|
|
}
|
|
|
|
func deleteTasks(args []string) error {
|
|
filter, err := engine.ParseFilter(args)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
tasks, err := engine.GetTasks(filter)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if len(tasks) == 0 {
|
|
fmt.Println("No tasks matched.")
|
|
return nil
|
|
}
|
|
|
|
fmt.Printf("Delete %d task(s)? (y/N): ", len(tasks))
|
|
var confirm string
|
|
fmt.Scanln(&confirm)
|
|
if confirm != "y" && confirm != "Y" {
|
|
return nil
|
|
}
|
|
|
|
for _, task := range tasks {
|
|
task.Delete(false) // Soft delete
|
|
}
|
|
|
|
fmt.Printf("Deleted %d task(s).\n", len(tasks))
|
|
return nil
|
|
}
|