-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathinquirer.node.txt
238 lines (200 loc) · 13.7 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
┏━━━━━━━━━━━━━━┓
┃ 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 ==> #2025-03-15
#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 rawlist
#Not with search
OPTS.required #BOOL. If false (def), allow undefined
#With input|number|checkbox
#With checkbox, means at least one must be checked
OPTS.validate #FUNC(STR)->[>]BOOL|'ERROR'. Whether input is accepted.
#With checkbox, argument is STR_ARR
#With number, argument is NUM
OPTS.transformer #FUNC(VAL[, { isFinal: BOOL }])->STR
#Transform what is displayed to users (not what is returned)
#With input|confirm
OPTS.choices #CHOICE_ARR or STR_ARR (both CHOICE.value|name)
#With select|rawlist|expand|checkbox
CHOICE.value #STR
CHOICE.name #STR (def: CHOICE.value). Shown before selection.
CHOICE.short #STR (def: CHOICE.name). Shown after selection
#Not with expand
CHOICE.key #'CHAR'
#With rawlist|expand
CHOICE.description #STR (def: ''). Shown after selection.
#Not with rawlist|expand
CHOICE.disabled #BOOL or STR (like true but with a message)
#Not with rawlist|expand
OPTS.pageSize #NUM (def: 7). Max items to show at once
#With select|search|checkbox
OPTS.loop #BOOL (def: true). When at the end, loops to beginning
#With select|checkbox
@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
COPTS.signal #ABORT_SIGNAL
EXIT ==> #Cleanly stopped on: SIGINT, process 'exit'
┌───────────┐
│ THEME │
└───────────┘
OPTS.theme #THEME
THEME.prefix #STR
#Or OBJ: idle STR (def: blue '?'), done STR (def: green '✔')
THEME.spinner.interval #NUM (def: 80)
THEME.spinner.frames #STR_ARR (def: cli-spinners 'dot', yellow)
THEME.style.STYLE #FUNC(STR[, STR2])->STR for rendering specific UI elements
#Possible STYLEs:
# - message (def: bold): all
# - STR2: 'loading', 'idle' (wait for input) or 'done' (input submitted)
# - answer (def: cyan): all but editor
# - error (def: red + '> ' prefix): all but confirm
# - help (def: dim): editor|password|checkbox|select|search
# - defaultAnswer (def: dim + '(...)'): input|number|expand|confirm|checkbox
# - highlight (def: cyan): rawlist|expand|checkbox|select|search
# - description (def: cyan): select|search
# - key (def: bold + '<...>'): editor|checkbox
# - disabledChoice (def: dim + '- ...'): checkbox
# - disabled (def: dim + '- ...'): select|search
# - searchTerm (def: cyan): search
THEME.style.renderSelectedChoices #FUNC(CHOICE_ARR, CHOICE|SEPARATOR_ARR2)->STR
#ARR is selected ones, ARR2 are all available ones
#How to render choices
#Def: 'CHOICE.name|value, ...'
#Only for select
THEME.icon.ICON #STR. Possible ICONs:
# - cursor (def: figures.pointer): select|search|checkbox
# - [un]checked (def: figures.circle[Filled]): checkbox
THEME.helpMode #Whether to display the help among:
# - 'auto' (def): hide after an interaction
# - 'never'
# - 'always'
#Only for select|search|checkbox
THEME.indexMode #Whether to show indices: 'hidden' (def) or 'number'
#Only for select
THEME.validationFailureMode #On error, whether to clear the input line: 'keep' (false, def) or 'clear' (true)
#Only for input|editor
┌─────────────┐
│ 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/number
NUMBER([OPTS[, COPTS]])->>NUM #
OPTS.min|max #NUM
OPTS.step #NUM (def: 1)
@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
OPTS.file #TEMP_OPTS. Temporary file options.
TEMP_OPTS.prefix #STR (def: '')
TEMP_OPTS.postfix #STR (def: '.txt')
TEMP_OPTS.mode #NUM (def: 0o644)
TEMP_OPTS.dir|template #See node-tmp
@inquirer/select
SELECT([OPTS[, COPTS]])->>STR #Chooses among multiple choices with an arrow and autocomplete
#Can use:
# - Up|Down j|k or CTRL-n|p to navigate
# - digits to select by index
@inquirer/rawlist
RAWLIST([OPTS[, COPTS]])->>STR #Same as @inquirer/select but shows indexes and a prompt to enter index
@inquirer/expand
EXPAND([OPTS[, COPTS]])->>STR #Same as @inquirer/select 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
@inquirer/search
SEARCH([OPTS[, COPTS]])->>STR #Same as @inquirer/select but using a FUNC to compute the CHOICEs
#Also, shows the autocomplete search box
OPTS.source #FUNC(STR|undefined, OBJ)->[>]CHOICE_ARR
#OBJ:
# - signal ABORT_SIGNAL: aborted when user cancels
@inquirer/checkbox
CHECKBOX([OPTS[, COPTS]]) #Same as @inquirer/select but multiple choice
->>STR_ARR #Can use keys: a (all), i (invert)
OPTS.prefix #STR
OPTS.instructions #STR|BOOL (def: true). Show keys help
OPTS.shortcuts.SHORTCUT #STR|null, for SHORTCUT 'all' (def: 'a') and 'invert' (def: 'i')
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)