(38 lines)
1 '\" t2 .\" Copyright (c) 2025 Bruce Hill3 .\" All rights reserved.4 .\"5 .TH ask 3 2025-11-29 "Tomo man-pages"6 .SH NAME7 ask \- get user input8 .SH LIBRARY9 Tomo Standard Library10 .SH SYNOPSIS11 .nf12 .BI ask\ :\ func(prompt:\ Text,\ bold:\ Bool\ =\ yes,\ force_tty:\ Bool\ =\ yes\ ->\ Text?)13 .fi14 .SH DESCRIPTION15 Gets a line of user input text with a prompt.18 .SH ARGUMENTS20 .TS21 allbox;22 lb lb lbx lb23 l l l l.24 Name Type Description Default25 prompt Text The text to print as a prompt before getting the input. -26 bold Bool Whether or not to print make the prompt appear bold on a console. yes27 force_tty Bool Whether or not to force the use of /dev/tty. yes28 .TE29 .SH RETURN30 A line of user input text without a trailing newline, or empty text if something went wrong (e.g. the user hit `Ctrl-D`).32 .SH NOTES33 When a program is receiving input from a pipe or writing its output to a pipe, this flag (which is enabled by default) forces the program to write the prompt to `/dev/tty` and read the input from `/dev/tty`, which circumvents the pipe. This means that `foo | ./tomo your-program | baz` will still show a visible prompt and read user input, despite the pipes. Setting this flag to `no` will mean that the prompt is written to `stdout` and input is read from `stdin`, even if those are pipes.35 .SH EXAMPLES36 .EX37 assert ask("What's your name? ") == "Arthur Dent"38 .EE