(203 lines)
4 Gets a line of user input text with a prompt.6 When a program is receiving input from a pipe or writing its7 output to a pipe, this flag (which is enabled by default) forces the program8 to write the prompt to `/dev/tty` and read the input from `/dev/tty`, which9 circumvents the pipe. This means that `foo | ./tomo your-program | baz` will10 still show a visible prompt and read user input, despite the pipes. Setting11 this flag to `no` will mean that the prompt is written to `stdout` and input12 is read from `stdin`, even if those are pipes.16 A line of user input text without a trailing newline, or empty text if17 something went wrong (e.g. the user hit `Ctrl-D`).22 The text to print as a prompt before getting the input.27 Whether or not to print make the prompt appear bold on a console.32 Whether or not to force the use of /dev/tty.34 assert ask("What's your name? ") == "Arthur Dent"39 Exits the program with a given status and optionally prints a message.43 This function never returns.49 If nonempty, this message will be printed (with a newline) before50 exiting.55 The status code that the program with exit with.57 exit("Goodbye forever!", Int32(1))62 Register a function that runs at cleanup time for Tomo programs. Cleanup63 time happens when a program exits (see `atexit()` in C), or immediately64 before printing error messages in a call to `fail()`. This allows for65 terminal cleanup so error messages can be visible as the program shuts66 down.68 Use this API very carefully, because errors that occur during cleanup69 functions may make it extremely hard to figure out what's going on. Cleanup70 functions should be designed to not error under any circumstances.75 A function to run at cleanup time.79 Nothing.81 at_cleanup(func()82 _ := (/tmp/file.txt).remove(ignore_missing=yes)83 )88 Gets an environment variable.92 If set, the environment variable's value, otherwise, `none`.97 The name of the environment variable to get.99 assert getenv("TERM") == "xterm-256color"100 assert getenv("not_a_variable") == none105 Prints a message to the console (alias for say()).109 Nothing.114 The text to print.119 Whether or not to print a newline after the text.121 print("Hello ", newline=no)122 print("world!")127 Prints a message to the console.131 Nothing.136 The text to print.141 Whether or not to print a newline after the text.143 say("Hello ", newline=no)144 say("world!")149 Sets an environment variable.153 Nothing.158 The name of the environment variable to set.162 The new value of the environment variable. If `none`, then the163 environment variable will be unset.165 setenv("FOOBAR", "xyz")170 Pause execution for a given number of seconds.174 Nothing.179 How many seconds to sleep for.181 sleep(1.5)186 Prints a message to the console, aborts the program, and prints a stack trace.190 Nothing, aborts the program.195 The error message to print.197 fail("Oh no!")203 Whether or not the console prefers ANSI color escape sequences in the output.