#!/usr/bin/env python3
import subprocess

installed = set(
    map(
        str.lower,
        subprocess.run(
            ["code", "--list-extensions"], stdout=subprocess.PIPE, check=True
        )
        .stdout.decode("utf-8")
        .split("\n"),
    )
)

desired = {
    "alefragnani.bookmarks",
    "bbenoist.nix",
    "be5invis.toml",
    "bkromhout.vscode-tcl",
    "dbaeumer.vscode-eslint",
    "editorconfig.editorconfig",
    "humao.rest-client",
    "justusadam.language-haskell",
    "lextudio.restructuredtext",
    "mhutchie.git-graph",
    "ms-azuretools.vscode-docker",
    "ms-dotnettools.csharp",
    "ms-python.python",
    "ms-vscode-remote.vscode-remote-extensionpack",
    "ms-vscode.cpptools",
    "ms-vscode.go",
    "ms-vsliveshare.vsliveshare",
    "mshr-h.veriloghdl",
    "oderwat.indent-rainbow",
    "rust-lang.rust",
    "scalameta.metals",
    "slevesque.perforce",
    "spmeesseman.vscode-taskexplorer",
    "visualstudioexptteam.vscodeintellicode",
}

for extension in desired:
    if extension in installed:
        print(f"Skipping {extension} since it is already installed")
    else:
        print(f"Installing {extension}")
        subprocess.run(["code", "--install-extension", extension], check=True)
