()
| 246 | } |
| 247 | |
| 248 | const 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) { |
no test coverage detected