()
| 324 | } |
| 325 | |
| 326 | export const runConfigureMenu = async (): Promise<number> => { |
| 327 | const action = await tuiPrompts.select({ |
| 328 | message: 'Configuration action', |
| 329 | options: [ |
| 330 | { value: 'list', label: 'List all settings' }, |
| 331 | { value: 'guided', label: 'Guided edit (common settings)' }, |
| 332 | { value: 'get', label: 'Advanced get by dot-path' }, |
| 333 | { value: 'set', label: 'Advanced set by dot-path' }, |
| 334 | { value: 'validate', label: 'Validate settings' }, |
| 335 | { value: 'back', label: 'Back' }, |
| 336 | ], |
| 337 | }) |
| 338 | |
| 339 | if (tuiPrompts.isCancel(action)) { |
| 340 | tuiPrompts.cancel('Cancelled') |
| 341 | return 1 |
| 342 | } |
| 343 | if (action === 'back') { |
| 344 | return 0 |
| 345 | } |
| 346 | |
| 347 | if (action === 'list') { |
| 348 | return runConfigList() |
| 349 | } |
| 350 | |
| 351 | if (action === 'validate') { |
| 352 | return runConfigValidate() |
| 353 | } |
| 354 | |
| 355 | if (action === 'guided') { |
| 356 | return runGuidedConfigureMenu() |
| 357 | } |
| 358 | |
| 359 | const category = await tuiPrompts.select({ |
| 360 | message: 'Configuration category', |
| 361 | options: [...getCategoryOptions(), { value: 'back', label: 'Back' }], |
| 362 | }) |
| 363 | if (tuiPrompts.isCancel(category)) { |
| 364 | tuiPrompts.cancel('Cancelled') |
| 365 | return 1 |
| 366 | } |
| 367 | if (category === 'back') { |
| 368 | return 0 |
| 369 | } |
| 370 | |
| 371 | const pathInput = await tuiPrompts.text({ |
| 372 | message: category === 'other' ? 'Full dot-path' : `Path inside ${category} (without "${category}.")`, |
| 373 | placeholder: category === 'other' ? 'payments.enabled' : 'enabled', |
| 374 | validate: (input) => (input.trim() ? undefined : 'Path is required'), |
| 375 | }) |
| 376 | if (tuiPrompts.isCancel(pathInput)) { |
| 377 | tuiPrompts.cancel('Cancelled') |
| 378 | return 1 |
| 379 | } |
| 380 | |
| 381 | const normalizedPath = pathInput.trim() |
| 382 | const path = category === 'other' ? normalizedPath : `${category}.${normalizedPath}` |
| 383 |
no test coverage detected