Tutorial
Build your executable
Check, format, and compile the finished tool.
Start with chapter 8's tasks.tea, task_list.tea, and saved tasks.txt. There are no source changes in this chapter. We'll check the program, run its tests, and build the executable you've been working toward.
Check and format
tea check tasks.tea task_list.tea
tea fmt tasks.tea task_list.tea
tea fmt --check tasks.tea task_list.tea
tea test "$PWD/task_list.tea"The checker should report zero errors and warnings. The formatter may report files it changed; its --check invocation should then succeed without requesting changes. The four main walkthrough tests should pass. If you kept the optional test from chapter 8, you'll see five instead.
tea check validates source without executing it. Tests exercise behavior, while building also verifies that your program can be linked into a native executable.
Build and run
tea build tasks.tea
./bin/tasks list --allThe build reports the output at bin/tasks; it may mention a cached build. The executable prints:
1. [ ] Learn Tea
2. [x] Build a CLI
3. [x] Take a break
4. [ ] Write a testIt reads the same tasks.txt because you ran it from the same directory. The entry file imports task_list.tea, so Tea compiles that module as part of the program. You don't build the two files separately.
Use it as a command-line tool
./bin/tasks add "Build something useful"
./bin/tasks done 1
./bin/tasks listAdded task 5.
Completed task 1.
4. [ ] Write a test
5. [ ] Build something usefulYou can copy the executable to another compatible machine without its Tea source files. Keep platform and architecture in mind: a native executable built for your machine isn't automatically a binary for every operating system. Your data file is separate from the executable, and its location remains relative to the directory where you run the command.
Check the command's exit status
./bin/tasks list --unknown
echo $?The tool writes tasks: invalid arguments; run tasks --help for usage to standard error, and echo prints 2. Help and successful operations return 0; malformed saved data or file failures return 1. Unlike the current script launcher, the compiled executable preserves these exact codes.
Final source
The complete two-file source is in Organize and test. The repository also contains runnable checkpoints for every source-changing chapter. You can revisit any checkpoint without recreating earlier exercises.
Try it yourself
Add an open command that marks a completed task as open again. Reuse the number validation from done, add a test, and update the help text.
Design hint
Extract the “text to valid task index” portion of complete_task into a private helper. Have both operations call it, then set the done field to the appropriate value. Keep returning whether a task changed so repeating either command doesn't rewrite the file unnecessarily.
Where to go next
You started with two lines of Tea and ended with a native tool that owns its data, validates input, handles failures, and has tests. For your next program, reuse the same progression: get a useful result, extract functions when they help, introduce structured data, and test the logic separately from the command interface.
Try a task search command, a different storage location supplied by an argument, or a new CLI entirely. Browse the examples for ideas, use the language guides to deepen your understanding, and keep the standard-library reference nearby.