MCPcopy Create free account
hub / github.com/cameri/nostream / getGuidedSettingValue

Function getGuidedSettingValue

src/cli/tui/menus/configure.ts:165–246  ·  view source on GitHub ↗
(setting: GuidedSetting, currentValue: unknown)

Source from the content-addressed store, hash-verified

163}
164
165const getGuidedSettingValue = async (setting: GuidedSetting, currentValue: unknown) => {
166 switch (setting.type) {
167 case 'boolean': {
168 const answer = await tuiPrompts.confirm({
169 message: `${setting.label} (current: ${formatCurrentValue(currentValue)})`,
170 initialValue: Boolean(currentValue),
171 })
172
173 if (tuiPrompts.isCancel(answer)) {
174 tuiPrompts.cancel('Cancelled')
175 return undefined
176 }
177
178 return {
179 rawValue: String(answer),
180 valueType: 'inferred' as const,
181 }
182 }
183 case 'select': {
184 const options = (setting.options ?? []).map((option) => ({
185 value: option,
186 label: option,
187 hint: option === currentValue ? 'current' : undefined,
188 }))
189
190 const answer = await tuiPrompts.select({
191 message: `${setting.label} (current: ${formatCurrentValue(currentValue)})`,
192 options: [...options, { value: 'back', label: 'Back' }],
193 })
194
195 if (tuiPrompts.isCancel(answer) || answer === 'back') {
196 tuiPrompts.cancel('Cancelled')
197 return undefined
198 }
199
200 return {
201 rawValue: answer,
202 valueType: 'inferred' as const,
203 }
204 }
205 case 'stringArray': {
206 const defaultValue = Array.isArray(currentValue) ? currentValue.join(', ') : ''
207 const answer = await tuiPrompts.text({
208 message: `${setting.label} (comma-separated)`,
209 defaultValue,
210 })
211
212 if (tuiPrompts.isCancel(answer)) {
213 tuiPrompts.cancel('Cancelled')
214 return undefined
215 }
216
217 const parsed = answer
218 .split(',')
219 .map((part) => part.trim())
220 .filter(Boolean)
221
222 return {

Callers 1

runGuidedConfigureMenuFunction · 0.85

Calls 1

formatCurrentValueFunction · 0.85

Tested by

no test coverage detected