// EditTask edits the corresponsing task to a new one
EditTask edits the corresponsing task to a new one
// EditTask edits the corresponsing task to a new one
func EditTask(path string, id int, name string, date string) error {
	tasks, err := ReadTasks(path)
	if err != nil {
		return err
	}
	var oldtask, newtask Task
	id = id - 1
	if id < len(tasks) {
		for i, _ := range tasks {
			if i == id {
				oldtask = tasks[i]
				newtask = Task{
					Date: date,
					Name: name,
					Done: " ",
				}
				tasks[i] = newtask
			}
		}
	} else {
		return fmt.Errorf("\nInvalid Task ID - %d \n", id+1)
	}
	err = WriteTasks(path, tasks, true)
	if err != nil {
		return err
	}
	msg := `
Edited:
  %s
To be:
  %s
`
	fmt.Printf(msg, oldtask.Name, newtask.Name)
	return nil
}
func EditTask ( path string , id int , name string , date string ) error { tasks , err := ReadTasks ( path ) if err != nil { return err } var oldtask , newtask Task id = id - 1 if id < len ( tasks ) { for i , _ := range tasks { if i == id { oldtask = tasks [ i ] newtask = Task { Date : date , Name : name , Done : " " , } tasks [ i ] = newtask } } } else { return fmt . Errorf ( " \n \n " , id + 1 ) } err = WriteTasks ( path , tasks , true ) if err != nil { return err } msg := `
Edited:
  %s

To be:
  %s

` fmt . Printf ( msg , oldtask . Name , newtask . Name ) return nil }
EditTask edits the corresponsing task to a new one
EditTask edits the corresponsing task to a new one
// Read old tasks and add new ones // Update Task // Write to file // Print