( plugin: QuickAdd, params: CliData, )
| 649 | } |
| 650 | |
| 651 | async function checkChoiceHandler( |
| 652 | plugin: QuickAdd, |
| 653 | params: CliData, |
| 654 | ): Promise<string> { |
| 655 | try { |
| 656 | const choice = resolveChoiceFromParams(plugin, params); |
| 657 | if (choice.type === "Multi") { |
| 658 | return serialize({ |
| 659 | ok: false, |
| 660 | command: CLI_COMMANDS.check, |
| 661 | error: "Multi choices are interactive and cannot be checked via CLI.", |
| 662 | choice: describeChoice(choice), |
| 663 | }); |
| 664 | } |
| 665 | |
| 666 | const variables = extractVariables(params, RESERVED_CHECK_PARAMS); |
| 667 | const choiceExecutor = new ChoiceExecutor( |
| 668 | plugin.app, |
| 669 | plugin, |
| 670 | ) as IChoiceExecutor; |
| 671 | setExecutorVariables(choiceExecutor, variables); |
| 672 | |
| 673 | const requirements = await collectChoiceRequirements( |
| 674 | plugin.app, |
| 675 | plugin, |
| 676 | choiceExecutor, |
| 677 | choice, |
| 678 | ); |
| 679 | const unresolved = getUnresolvedRequirements( |
| 680 | requirements, |
| 681 | choiceExecutor.variables, |
| 682 | ); |
| 683 | const summarize = isTruthy(params.fields) |
| 684 | ? toDetailedFieldSummary |
| 685 | : toMissingFieldSummary; |
| 686 | |
| 687 | return serialize({ |
| 688 | ok: unresolved.length === 0, |
| 689 | command: CLI_COMMANDS.check, |
| 690 | choice: describeChoice(choice), |
| 691 | requiredInputCount: requirements.length, |
| 692 | missingInputCount: unresolved.length, |
| 693 | missing: unresolved.map(summarize), |
| 694 | missingFlags: unresolved.map( |
| 695 | (requirement) => `value-${requirement.id}=<value>`, |
| 696 | ), |
| 697 | }); |
| 698 | } catch (error) { |
| 699 | return serialize({ |
| 700 | ok: false, |
| 701 | command: CLI_COMMANDS.check, |
| 702 | error: error instanceof Error ? error.message : String(error), |
| 703 | }); |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | /** |
| 708 | * Starts an *interactive* run: the choice executes immediately with a remote |
no test coverage detected