Toit on your computer
A language for your everyday tools.
Write a script, run it, and build on it. Toit works on your computer without an embedded device; many of the tools in the SDK are themselves written in Toit.
Install Toit →Your first command-line tool
Install the SDK, save this program as greet.toit, and run the command shown here.
The main function receives the program’s arguments. A block visits each name and prints
a greeting.
There is no project setup needed for this example.
main arguments:
if arguments.is-empty:
print "Usage: greet.toit NAME ..."
return
arguments.do: |name|
print "Hello, $name!"
$ toit run greet.toit -- Ada Linus
Hello, Ada! Hello, Linus!
The CLI package
Build command-line applications.
pkg-cli provides argument parsing, typed options, subcommands, and generated help. It also supports shell completion for Bash, Zsh, and Fish.
The toit command-line tool is itself written in Toit, using this package.
Read its source for a larger example →
As a tool grows, the same package provides configuration storage, caching, and output with selectable verbosity and text or JSON formats.
toit pkg install github.com/toitlang/pkg-cli
See a command-line application example →A readable language
Indentation gives code its structure. Lambdas and blocks let you pass behavior to functions. Classes and types help describe larger programs.
Explore the language →Tools that belong together
The Toit command includes running programs, analysis, and package management. The editor extension adds navigation, diagnostics, and completion.
Editor integration →Libraries to build on
Explore the standard library for files, collections, and networking. Find community packages or publish your own.
Standard library →Package registry →
Start with the work you have.
Toit is worth trying for small utilities, automation, and data processing. The standard library and community packages provide a starting point for your own tools.
For a next step, follow the language guide or learn about package management.
Working with hardware too? Use Toit on an ESP32 →