1 import { compare } from "semver";
2 import { type PicoSDK, detectInstalledSDKs } from "../utils/picoSDKUtil.mjs";
3 import { Command } from "./command.mjs";
4 import { window } from "vscode";
5 import type Settings from "../settings.mjs";
6 import { SettingsKey } from "../settings.mjs";
7 import type UI from "../ui.mjs";
9 export default class SwitchSDKCommand extends Command {
10 private _settigs: Settings;
13 constructor(settings: Settings, ui: UI) {
16 this._settigs = settings;
20 async execute(): Promise<void> {
21 const availableSDKs = (await detectInstalledSDKs()).sort((a, b) =>
22 compare(a.version, b.version)
25 const selectedSDK = await window.showQuickPick<PicoSDK>(availableSDKs, {
26 placeHolder: "Select Pico SDK",
28 ignoreFocusOut: false,
29 title: "Switch Pico SDK",
36 // TODO: maybe ensure workspace settings are used
37 // save selected SDK version to settings
38 await this._settigs.update(SettingsKey.picoSDK, selectedSDK.version);
39 this._ui.updateSDKVersion(selectedSDK.version);