code / ask

Lines831 C761 make38 Markdown32
(92 lines)
1 .\" Manpage for ask.
2 .\" Contact bruce@bruce-hill.com to correct errors or typos.
3 .TH man 8 "4 June 2019" "1.0" "ask manual page"
4 .SH NAME
5 ask \- A tiny command line tool for getting user input
6 .SH SYNOPSIS
7 .B ask
8 [\fI-Q\fR|\fI--quickpick\fR]
9 [\fI-P\fR|\fI--password\fR]
10 [\fI-0\fR|\fI--read0\fR]
11 [\fI-y\fR|\fI--yes\fR]
12 [\fI-n\fR|\fI--no\fR]
13 [(\fI-H \fR|\fI--history=\fR) name]
14 [\fI-h\fR|\fI--help\fR]
15 [\fI-v\fR|\fI--version\fR]
16 [(\fI-q\fR |\fI--query=\fR) initial]
17 [(\fI-p\fR |\fI--prompt=\fR) prompt]
18 [\fIoptions...\fR]
19 .SH DESCRIPTION
20 \fBask\fR is a tiny console application that displays a prompt, gets user input
21 (with line editing and fuzzy finding functionality), and prints the result to
22 standard output
23 .SH OPTIONS
24 .B \-Q
25 .B \--quickpick
26 When used with fuzzy finding, as soon as exactly one match is found, exit and
27 print it.
29 .B \-P
30 .B \--password
31 Use password mode, which does not print user input as it's being typed.
33 .B \-0
34 .B \--read0
35 Read input delineated by NULL bytes instead of newlines.
37 .B \-v
38 .B \--version
39 Print \fBask\fR's version and exit.
41 .B \-h
42 .B \--help
43 Print \fBask\fR's usage and exit.
45 .B \-q <query>
46 .B \--query=<query>
47 If given, pre-populate the user input with this value.
49 .B \-p <prompt>
50 .B \--prompt=<prompt>
51 If provided, display the given prompt in bold. If the \fI-p\fR and
52 \fI--prompt=\fR flags are not used, the first positional argument is used as
53 the prompt, or \fB"> "\fR if there are no positional arguments.
55 .B \-H <file>
56 .B \--history=<file>
57 Use the given file as a history file. With a history file, you can browse
58 previously selected values with the up/down arrow keys.
60 .B \-y
61 .B \--yes
62 Quickpick between "y" and "n" with "[Y/n]" appended to the prompt, exiting with
63 success if "n" is not chosen.
65 .B \-n
66 .B \--no
67 Quickpick between "y" and "n" with "[y/N]" appended to the prompt, exiting with
68 failure if "y" is not chosen.
70 .B options...
71 If additional command line arguments are provided, or if any input is piped in,
72 \fBask\fR will operate in fuzzy finding mode, attempting to pick one of the
73 given options.
75 .SH EXAMPLES
76 .TP
77 .B
78 foo="`ask 'What is foo? '`"
79 Store user input in a variable. (Equivalent of \fBread -p 'What is foo? ' foo\fR)
81 .TP
82 .B
83 rm "`ls | ask 'Delete file: '`"
84 Fuzzy find a file. (Equivalent of \fBrm "`ls | fzf --prompt='Delete file: '`"\fR)
86 .TP
87 .B
88 if ask -y 'Do thing? '; then dothing; fi
89 Ask user for confirmation (default: yes).
91 .SH AUTHOR
92 Bruce Hill (bruce@bruce-hill.com)