Tea — a strongly typed scripting language
Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

Agent documentationContributingCommunityRepository

Get Started

InstallationGetting StartedCLI

Tutorial

Build a CLI with Tea1. Display your first task2. Display several tasks3. Track task status4. Accept commands5. Read saved tasks6. Add tasks7. Complete tasks8. Organize and test9. Build your executable

Language

SyntaxTypesFunctionsStructsGenericsPattern MatchingError HandlingModulesTesting

Project

Code StyleContributing

Read as Markdown

Tutorial

Build your executable

Check, format, and compile the finished tool.

Chapter 9 of 9 · Build a CLI with Tea

Choose a chapter
  1. Build a CLI with Tea
  2. 1. Display your first task
  3. 2. Display several tasks
  4. 3. Track task status
  5. 4. Accept commands
  6. 5. Read saved tasks
  7. 6. Add tasks
  8. 7. Complete tasks
  9. 8. Organize and test
  10. 9. Build your executable

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 --all

The 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 test

It 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 list
Added task 5.
Completed task 1.
4. [ ] Write a test
5. [ ] Build something useful

You 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.

Previous8. Organize and testKeep buildingExplore more Tea programs