Пример #1
0
func cmdListShow(listName string) (err error) {
	list, err := getListByShortName(listName)
	if err != nil {
		return
	}

	tasks, err := api.GetListTasks(list)
	if err != nil {
		return
	}

	fmt.Printf("Tasks from \"%s\" list:\n\n", list.Title)
	for _, el := range tasks {
		fmt.Printf("    - %s\n", el.Title)
	}
	fmt.Println()

	return
}
Пример #2
0
// Outputs list tasks and asks for one of it.
func askForTask(list api.List) (task api.Task, err error) {
	tasks, err := api.GetListTasks(list)
	if err != nil {
		return
	}

	for i, el := range tasks {
		fmt.Printf("  [%d] %s\n", i+1, el.Title)
	}
	fmt.Println()

	fmt.Print("What is the number of the task? ")
	var taskNo int
	fmt.Scanln(&taskNo)
	fmt.Println()

	if taskNo > len(tasks) || taskNo < 1 {
		err = errors.New("Incorrect input.")
		return
	}

	return tasks[taskNo-1], nil
}