Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddCmd = &cobra.Command{ Use: "add", Short: "Add a new task", Run: func(cmd *cobra.Command, args []string) { tasks := &handlers.Tasks{} err := tasks.Load(taskFile) throwErr(err) if taskName == "" { throwErr(errors.New("task name cannot be empty")) } err = tasks.Add(taskName) throwErr(err) err = tasks.Save(taskFile) throwErr(err) log.Println("Task added successfully") }, }
addCmd represents the add command
View Source
var DeleteAllCmd = &cobra.Command{ Use: "deleteall", Short: "Delete all tasks", Run: func(cmd *cobra.Command, args []string) { tasks := &handlers.Tasks{} err := tasks.Load(taskFile) throwErr(err) err = tasks.DeleteAll() throwErr(err) err = tasks.Save(taskFile) throwErr(err) log.Println("All tasks deleted successfully") }, }
deleteAllCmd represents the deleteAll command
View Source
var DeleteCmd = &cobra.Command{ Use: "delete", Short: "Delete a task by ID", Run: func(cmd *cobra.Command, args []string) { tasks := &handlers.Tasks{} err := tasks.Load(taskFile) throwErr(err) if deleteTaskID <= 0 { throwErr(errors.New("task ID cannot be less than or equal to zero")) } err = tasks.Delete(deleteTaskID) throwErr(err) err = tasks.Save(taskFile) throwErr(err) log.Println("Task deleted successfully") }, }
deleteCmd represents the delete command
View Source
var DoneCmd = &cobra.Command{ Use: "done", Short: "Mark a task as done", Run: func(cmd *cobra.Command, args []string) { tasks := &handlers.Tasks{} err := tasks.Load(taskFile) throwErr(err) if doneTaskID <= 0 { throwErr(errors.New("task ID cannot be less than or equal to zero")) } err = tasks.Done(doneTaskID) throwErr(err) err = tasks.Save(taskFile) throwErr(err) log.Println("Task marked as done successfully") }, }
doneCmd represents the done command
View Source
var ListCmd = &cobra.Command{ Use: "list", Short: "List all tasks", Run: func(cmd *cobra.Command, args []string) { tasks := &handlers.Tasks{} err := tasks.Load(taskFile) throwErr(err) err = tasks.List() throwErr(err) }, }
listCmd represents the list command
View Source
var UpdateCmd = &cobra.Command{ Use: "update", Short: "Update a task by ID", Run: func(cmd *cobra.Command, args []string) { tasks := &handlers.Tasks{} err := tasks.Load(taskFile) throwErr(err) if updateTaskId <= 0 { throwErr(errors.New("task ID cannot be less than or equal to zero")) } if message == "" { throwErr(errors.New("message cannot be empty")) } err = tasks.Update(updateTaskId, message) throwErr(err) err = tasks.Save(taskFile) throwErr(err) log.Println("Task updated successfully") }, }
updateCmd represents the update command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.