// WipeTasks removes all the tasks
// If doneOnly flag is provided, only the finished tasks will be wiped
WipeTasks removes all the tasks
If doneOnly flag is provided, only the finished tasks will be wiped
// WipeTasks removes all the tasks // If doneOnly flag is provided only the finished tasks will be wiped
func WipeTasks(path string, doneOnly bool) error {
	var (
		tasks []Task
		count int
	)
	if doneOnly {
		allTasks, err := ReadTasks(path)
		if err != nil {
			return err
		}
		for _, task := range allTasks {
			if task.Done == "x" {
				continue
			} else {
				tasks = append(tasks, task)
			}
			err := WriteTasks(path, tasks, true)
			if err != nil {
				return err
			}
		}
		count = len(allTasks) - len(tasks)
	} else {
		err := WriteTasks(path, tasks, true)
		if err != nil {
			return err
		}
	}
	if doneOnly {
		fmt.Printf("\n%d todo tasks removed. \n", count)
	} else {
		fmt.Println("\nAll todo tasks removed.")
	}
	return nil
}
func WipeTasks ( path string , doneOnly bool ) error { var ( tasks [ ] Task count int ) if doneOnly { allTasks , err := ReadTasks ( path ) if err != nil { return err } for _ , task := range allTasks { if task . Done == " " { continue } else { tasks = append ( tasks , task ) } err := WriteTasks ( path , tasks , true ) if err != nil { return err } } count = len ( allTasks ) - len ( tasks ) } else { err := WriteTasks ( path , tasks , true ) if err != nil { return err } } if doneOnly { fmt . Printf ( " \n \n " , count ) } else { fmt . Println ( " \n " ) } return nil }
WipeTasks removes all the tasks
If doneOnly flag is provided, only the finished tasks will be wiped
WipeTasks removes all the tasks If doneOnly flag is provided only the finished tasks will be wiped
// write back undone task to todd // wipe all // Print message