resolveSetupTargets resolves the App/API selection, prompting when allowed.
(inputs *SetupInputs, canPromptFlag bool)
| 684 | |
| 685 | // resolveSetupTargets resolves the App/API selection, prompting when allowed. |
| 686 | func resolveSetupTargets(inputs *SetupInputs, canPromptFlag bool) error { |
| 687 | if inputs.App || inputs.API { |
| 688 | return nil |
| 689 | } |
| 690 | if !canPromptFlag { |
| 691 | return fmt.Errorf("in --no-input mode, specify at least one of --app or --api") |
| 692 | } |
| 693 | |
| 694 | const ( |
| 695 | optApp = "App Only" |
| 696 | optAPI = "API (Associate with an App)" |
| 697 | ) |
| 698 | |
| 699 | var selection string |
| 700 | q := prompt.SelectInput( |
| 701 | "setup-target", |
| 702 | "What do you want to create?", |
| 703 | "Select App to create an application, or API to create an API linked to an app.", |
| 704 | []string{optApp, optAPI}, |
| 705 | optApp, |
| 706 | true, |
| 707 | ) |
| 708 | if err := prompt.AskOne(q, &selection); err != nil { |
| 709 | return fmt.Errorf("failed to select target resource: %w", err) |
| 710 | } |
| 711 | |
| 712 | switch selection { |
| 713 | case optApp: |
| 714 | inputs.App = true |
| 715 | case optAPI: |
| 716 | inputs.API = true |
| 717 | default: |
| 718 | return fmt.Errorf("unexpected selection: %q", selection) |
| 719 | } |
| 720 | return nil |
| 721 | } |
| 722 | |
| 723 | // resolveAPIAppLink handles the API flow's app-linking decision. |
| 724 | // It either sets inputs.LinkedAppID (via picker or flag) or flips inputs.App=true |
no test coverage detected