Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

ContributingCommunityRepository

Runnable Examples

echogreptodoteam_scoreboard

Runnable Examples

todo

A persistent task list CLI built in Tea.

What it demonstrates

  • Persists state to disk with std.fs and std.path.
  • Uses std.env for configurable file location and std.args for subcommands.

Run it

tea examples/todo/main.tea
tea build examples/todo/main.tea
./bin/main

README summary

A persistent todo list application that stores tasks in a text file. It supports adding, listing, completing, and removing tasks, with a configurable location through TODO_FILE.

todo/main.tea

use args = "std.args"
use env = "std.env"
use fs = "std.fs"
use path = "std.path"

def char_to_digit(c: String) -> Int
  if c == "0"
    return 0
  else if c == "1"
    return 1
  else if c == "2"
    return 2
  else if c == "3"
    return 3
  else if c == "4"
    return 4
  else if c == "5"
    return 5
  else if c == "6"
    return 6
  else if c == "7"
    return 7
  else if c == "8"
    return 8
  else if c == "9"
    return 9
  else
    return - 1
  end
end

def parse_int(s: String) -> Int
  var result = 0
  var i = 0

  while i < @len(s)
    const c = s[i]
    const digit = char_to_digit(c)

    if digit >= 0
      result = result * 10 + digit
    else
      @eprintln(`todo: invalid number '${s}'`)
      @exit(1)
    end

    i = i + 1
  end

  return result
end

def get_todo_file() -> String
  const custom_path = env.get("TODO_FILE")

  if @len(custom_path) > 0
    return custom_path
  end

  const home = env.get("HOME")
  return path.join([home, ".todo.txt"])
end

def init_todo_file() -> Void
  const filepath = get_todo_file()
  fs.write_file(filepath, "")
  @println(`Initialized ${filepath}`)
end

Related pages

Continue to

std.env

This example reads `TODO_FILE` from the environment.

Continue to

std.path

See the path helpers used for the todo file location.