async function switchProfile()

in src/extension.js [333:365]


async function switchProfile() {
  const quickPick = vscode.window.createQuickPick();
  quickPick.placeholder = vscode.l10n.t('Select a profile');

  const items = [];

  const config = await loadProfiles();
  const profiles = config.profiles;

  for (const profile of profiles) {
    let label = `$(account) ${profile.name}`;
    if (profile.name === config.current) {
      label = `$(account) ${profile.name} $(check)`
    }

    items.push({
      profile: profile.name,
      label: label,
      detail: `mode: ${profile.mode}, default region: ${profile.region_id}`
    });
  }

  quickPick.items = items;

  quickPick.onDidAccept(async () => {
    vscode.window.showInformationMessage(`Switching profile to ${quickPick.selectedItems[0].profile}, done`);
    config.current = quickPick.selectedItems[0].profile;
    await saveProfiles(config);
    quickPick.dispose();
  });

  quickPick.show();
}