<commit_before>package command

import (
	"fmt"

	"github.com/urfave/cli"
)

var Next = cli.Command{
	Name:   "next",
	Usage:  "Show a next undone todo",
	Action: next,
}

func next(c *cli.Context) error {
	path := todoFilePath()
	todos, err := readTodos(path)
	if err != nil {
		return err
	}

	for _, todo := range todos {
		if todo.Done {
			continue
		}
		fmt.Printf("%s\n", todo.Title)
		return nil
	}

	return nil
}<commit_msg>Show a next undone subtodo by next command<commit_after>package command

import (
	"fmt"

	"github.com/naoty/todo/todo"
	"github.com/urfave/cli"
)

var Next = cli.Command{
	Name:   "next",
	Usage:  "Show a next undone todo",
	Action: next,
}

func next(c *cli.Context) error {
	path := todoFilePath()
	todos, err := readTodos(path)
	if err != nil {
		return err
	}

	todo, found := nextTodoFromTodos(todos)
	if found {
		fmt.Println(todo.Title)
	}

	return nil
}

func nextTodoFromTodos(todos []todo.Todo) (todo.Todo, bool) {
	for _, todo := range todos {
		if todo.Done {
			continue
		}

		if len(todo.Todos) > 0 {
			return nextTodoFromTodos(todo.Todos)
		}

		return todo, true
	}

	return todo.Todo{}, false
}
{'fraction_non_alphanumeric': 0.13687881429816914, 'fraction_numerical': 0.0008718395815170009, 'mean_word_length': 3.299625468164794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5582152', 'n_tokens_mistral': 503, 'n_tokens_neox': 473, 'n_words': 116}