-
Notifications
You must be signed in to change notification settings - Fork 16
/
inquirer.node.txt
177 lines (142 loc) · 11.2 KB
/
inquirer.node.txt
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
INQUIRER
ALTERNATIVES ==> # - inquirer (preferred)
# - node-promptly: minimal but relies on unmaintained code
# - terkelg prompts: not well maintained
# - enquirer: not maintained
# - flatiron prompt: not maintained
VERSION ==> #2023-10-22
#Is a Node module
/=+===============================+=\
/ : : \
)==: COMMON :==(
\ :_______________________________: /
\=+===============================+=/
@inquirer/TYPE #Each prompt type. Can be used on its own
@inquirer/prompts #OBJ re-exporting:
# - @inquirer/TYPE for all prompt types
# - Separator from @inquirer/core
@inquirer/core #Base module used by all prompt types
#Only used for custom prompt types.
#Not documented yet
OPTS.message #[>]STR[()]
OPTS.default #VAL. With all but select|rawlist
OPTS.validate #FUNC(STR)->[>]BOOL|'ERROR'. Whether input is accepted.
#With all but checkbox
OPTS.transformer #FUNC(VAL[, { isFinal: BOOL }])->STR
#Transform what is displayed to users (not what is returned)
#With input|confirm
OPTS.choices #CHOICE_ARR
#With select|rawlist|expand|checkbox
CHOICE.value #STR
CHOICE.name #STR (def: CHOICE.value). Shown before selection.
@inquirer/core
new Separator([STR]) #CHOICE used as visual separator (def STR "──────────────")
COPTS.input #ISTREAM (def: process.stdin)
COPTS.output #OSTREAM (def: process.stdout)
COPTS.clearPromptOnDone #BOOL (def: false). Clear screen after answer
EXIT ==> #Cleanly stopped on: SIGINT, process 'exit'
/=+===============================+=\
/ : : \
)==: PROMPTS :==(
\ :_______________________________: /
\=+===============================+=/
@inquirer/input
INPUT([OPTS[, COPTS]])->>STR #Normal prompt
@inquirer/confirm
CONFIRM([OPTS[, COPTS]])->>BOOL #Yes/No
#Looks for "y[es]", case-insensitively
#Def: true
@inquirer/password
PASSWORD([OPTS[, COPTS]])->STR #Prompt that hides input
OPTS.mark #BOOL|'CHAR'. Used to mask input
#true: like '*'
#false (def): show '[hidden]' (i.e. does not show input length)
@inquirer/editor
EDITOR([OPTS[, COPTS]])->>STR #Uses machine-specific text editor for user to enter, based on:
# - ENVVAR VISUAL|EDITOR
# - otherwise, "notepad" (Windows) or "vim" (Unix)
#Uses a temporary file
OPTS.postfix #'.EXT' (def: '.txt') of the file to edit
OPTS.waitForUseInput #BOOL (def: true). Do not open editor until confirmation
@inquirer/select
SELECT([OPTS[, COPTS]])->>STR #Chooses among multiple choices with an arrow
#Can use:
# - Up|Down j|k or CTRL-n|p to navigate
# - digits to select by index
OPTS.pageSize #NUM (def: 7). Max items to show at once
OPTS.loop #BOOL (def: true). When at the end, loops to beginning
CHOICE.description #STR (def: ''). Shown after selection.
CHOICE.disabled #BOOL or STR (like true but with a message)
@inquirer/rawlist
RAWLIST([OPTS[, COPTS]])->>STR #Same as @inquirer/list but shows indexes and a prompt to enter index
CHOICE.key #'CHAR'
@inquirer/expand
EXPAND([OPTS[, COPTS]])->>STR #Same as @inquirer/list but chooses by typing letter, which shows the option.
#Also include "h" to show all possible options
# - shown also when submitting empty answer
OPTS.expanded #BOOL (def: false). Show all choices
CHOICE.key #'CHAR'
@inquirer/checkbox
CHECKBOX([OPTS[, COPTS]])->>STR_ARR #Same as @inquirer/list but multiple choice
#Can use keys: a (all), i (invert)
OPTS.pageSize|loop #Same as @inquirer/select
OPTS.required #BOOL (def: false). At least one must be checked
OPTS.prefix #STR
OPTS.instructions #STR|BOOL (def: true). Show keys help
CHOICE.disabled #Same as @inquirer/list
CHOICE.checked #BOOL (def: false). Whether checked by default.
/=+===============================+=\
/ : : \
)==: CUSTOM PROMPTS :==(
\ :_______________________________: /
\=+===============================+=/
CUSTOM PROMPTS ==> ##None of the above works with the new API, i.e. must use the old API to use them
TYPE "emoji" ##STR
##Select emoji by entering words.
##Based on inquirer-autocomplete-prompt, i.e. can use same options
## - uses emoj (see its doc) as QUESTION.source
##Module "inquirer-emoji" (1.0.2)
TYPE "date" ##DATE
##Select a date + time with arrows.
## - CTRL-Arrow to change by 10, CTRL-ALT-Arrow to change by 100
##QUESTION.default is now by default
##Adds to QUESTION:
## - locale 'LOCALE'[_ARR]
## - format OBJ: Intl.DateTimeFormat's options
## - clearable BOOL (def: false): delete|backspace submits and returns null
##Adds to QUESTION.transformer's OPTS:
## - isDirty BOOL: user changed the date
## - isFinal BOOL: user submitted
## - isCleared BOOL: user cleared (see clearable)
##Module "inquirer-date-prompt" (3.0.0)
TYPE "selection" ##'PATH'
##Select a local file
##Adds to QUESTION:
## - multiple BOOL (def: false): multiple selection. Returns 'PATH'_ARR
## - root 'DIR' (def: cwd): which directory is shown
## - enableGoUpperDirectory BOOL (def: false): allow going up
## - onlyShowDir BOOL (def: false): only show directories, not regular files
## - onlyShowValid BOOL (def: false): hide files whose filename does not match QUESTION.validate()
## - hideChildrenOfValid BOOL (def: false): hide children of directories which do match QUESTION.validate()
## - states OBJ_ARR:
## - state 'ignored|selected'
## - label STR
##Adds to QUESTION.transformer's OPTS:
## - isFinal BOOL: user submitted
##Module "inquirer-file-tree-selection-prompt" (2.0.5)
TYPE "autocomplete" ##STR
##Like "list" but the list can be changed based on current input, enabling autocomplete
##Adds to QUESTION:
## - source(ANSWERS, STR|undefined)->>STR2_ARR (required)
## - STR is current input
## - STR2_ARR are choices
## - if source() is called while a previous call is still ongoing, the previous one is ignored
## - suggestOnly BOOL:
## - if false (def), the answer matches the current selection even if user typed something else
## - when false, QUESTION.validate() is called with CHOICE instead of STR
## - if true, tab autocompletes
## - searchText STR (def: 'Searching...'): shown while PROMISE unresolved
## - emptyText STR (def: 'No results...'): shown if STR2_ARR empty
##Module "inquirer-autocomplete-prompt" (3.0.1)