aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-ask.3
blob: 0303d0627f0e8332a3451f3f91bfceb8ef822e59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH ask 3 2025-04-21 "Tomo man-pages"
.SH NAME
ask \- get user input
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI ask\ :\ func(prompt:\ Text,\ bold:\ Bool\ =\ yes,\ force_tty:\ Bool\ =\ yes\ ->\ Text?)
.fi
.SH DESCRIPTION
Gets a line of user input text with a prompt.


.SH ARGUMENTS

.TS
allbox;
lb lb lbx lb
l l l l.
Name	Type	Description	Default
prompt	Text	The text to print as a prompt before getting the input. 	-
bold	Bool	Whether or not to print make the prompt appear bold on a console. 	yes
force_tty	Bool	Whether or not to force the use of /dev/tty. 	yes
.TE
.SH RETURN
A line of user input text without a trailing newline, or empty text if something went wrong (e.g. the user hit `Ctrl-D`).

.SH NOTES
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.

.SH EXAMPLES
.EX
>> ask("What's your name? ")
= "Arthur Dent"
.EE