(opts: {
projectChoice: ProjectChoice;
existingScheme?: string;
executor: CommandExecutor;
prompter: Prompter;
isTTY: boolean;
quietOutput: boolean;
})
| 495 | } |
| 496 | |
| 497 | async function selectScheme(opts: { |
| 498 | projectChoice: ProjectChoice; |
| 499 | existingScheme?: string; |
| 500 | executor: CommandExecutor; |
| 501 | prompter: Prompter; |
| 502 | isTTY: boolean; |
| 503 | quietOutput: boolean; |
| 504 | }): Promise<string> { |
| 505 | const schemeArgs = |
| 506 | opts.projectChoice.kind === 'workspace' |
| 507 | ? { workspacePath: opts.projectChoice.absolutePath } |
| 508 | : { projectPath: opts.projectChoice.absolutePath }; |
| 509 | |
| 510 | const schemes = await withSpinner({ |
| 511 | isTTY: opts.isTTY, |
| 512 | quietOutput: opts.quietOutput, |
| 513 | startMessage: 'Loading schemes...', |
| 514 | stopMessage: 'Schemes loaded.', |
| 515 | task: () => listSchemes(schemeArgs, opts.executor), |
| 516 | }); |
| 517 | |
| 518 | if (schemes.length === 0) { |
| 519 | throw new Error('No schemes were found for the selected project/workspace.'); |
| 520 | } |
| 521 | |
| 522 | const defaultIndex = |
| 523 | opts.existingScheme != null ? schemes.findIndex((scheme) => scheme === opts.existingScheme) : 0; |
| 524 | |
| 525 | showPromptHelp( |
| 526 | 'Select a scheme to set the default used when you do not pass --scheme.', |
| 527 | opts.quietOutput, |
| 528 | ); |
| 529 | return opts.prompter.selectOne({ |
| 530 | message: 'Select a scheme', |
| 531 | options: schemes.map((scheme) => ({ value: scheme, label: scheme })), |
| 532 | initialIndex: defaultIndex >= 0 ? defaultIndex : 0, |
| 533 | }); |
| 534 | } |
| 535 | |
| 536 | function getDefaultSimulatorIndex( |
| 537 | simulators: ListedSimulator[], |
no test coverage detected