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

Function runGuidedConfigureMenu

src/cli/tui/menus/configure.ts:248–324  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

246}
247
248const runGuidedConfigureMenu = async (): Promise<number> => {
249 const category = await tuiPrompts.select({
250 message: 'Configuration category',
251 options: [...guidedCategories.map(({ value, label }) => ({ value, label })), { value: 'back', label: 'Back' }],
252 })
253
254 if (tuiPrompts.isCancel(category)) {
255 tuiPrompts.cancel('Cancelled')
256 return 1
257 }
258 if (category === 'back') {
259 return 0
260 }
261
262 const selectedCategory = guidedCategories.find((entry) => entry.value === category)
263 if (!selectedCategory) {
264 tuiPrompts.cancel('Unknown category')
265 return 1
266 }
267
268 const settings = loadMergedSettings() as unknown as Record<string, unknown>
269 const setting = await tuiPrompts.select({
270 message: `${selectedCategory.label} setting`,
271 options: [
272 ...selectedCategory.settings.map((entry) => ({
273 value: entry.path,
274 label: entry.label,
275 hint: `current: ${formatCurrentValue(getByPath(settings, entry.path))}`,
276 })),
277 { value: 'back', label: 'Back' },
278 ],
279 })
280
281 if (tuiPrompts.isCancel(setting)) {
282 tuiPrompts.cancel('Cancelled')
283 return 1
284 }
285 if (setting === 'back') {
286 return 0
287 }
288
289 const selectedSetting = selectedCategory.settings.find((entry) => entry.path === setting)
290 if (!selectedSetting) {
291 tuiPrompts.cancel('Unknown setting')
292 return 1
293 }
294
295 const currentValue = getByPath(settings, selectedSetting.path)
296 const nextValue = await getGuidedSettingValue(selectedSetting, currentValue)
297 if (!nextValue) {
298 return 1
299 }
300
301 const confirmedSave = await tuiPrompts.confirm({
302 message: `Save ${selectedSetting.label}?`,
303 initialValue: true,
304 })
305 if (tuiPrompts.isCancel(confirmedSave) || !confirmedSave) {

Callers 1

runConfigureMenuFunction · 0.85

Calls 5

loadMergedSettingsFunction · 0.90
getByPathFunction · 0.90
runConfigSetFunction · 0.90
formatCurrentValueFunction · 0.85
getGuidedSettingValueFunction · 0.85

Tested by

no test coverage detected