дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
Adds Install/Uninstall 'openidea' Command actions. macOS uses the bundle launcher, Windows a user PATH wrapper and named pipe, and Linux the executable/AppImage path with a PATH hint. Files, folders, positions and `diff` go to the running app or start it. Closes #1286 Co-authored-by: jaw52 <[email protected]>
74 рядки
2.1 KiB
TypeScript
74 рядки
2.1 KiB
TypeScript
/** Install / Uninstall the `openidea` shell command. */
|
|
import type { Action } from "@/platform/actions";
|
|
import { tx } from "@/platform/i18n";
|
|
import { call, commands, isCancelled } from "@/platform/ipc";
|
|
import { notifications } from "@/workbench/contributions";
|
|
|
|
const KEY = "app.cli";
|
|
|
|
function errorText(e: unknown) {
|
|
return e instanceof Error ? e.message : String(e);
|
|
}
|
|
|
|
async function installCli(): Promise<void> {
|
|
try {
|
|
const result = await call(commands.appCliInstall());
|
|
const hint = result.pathDirectory
|
|
? tx`Add ${result.pathDirectory} to the beginning of PATH, then open a new terminal.`
|
|
: tx("Open a new terminal to use the openidea command.");
|
|
notifications().notify({
|
|
level: "info",
|
|
title: tx("The openidea command is installed"),
|
|
body: `${result.path}\n${hint}`,
|
|
key: KEY,
|
|
});
|
|
} catch (e) {
|
|
if (!isCancelled(e))
|
|
notifications().notify({
|
|
level: "error",
|
|
title: tx("Cannot install the openidea command"),
|
|
body: errorText(e),
|
|
key: KEY,
|
|
});
|
|
}
|
|
}
|
|
|
|
async function uninstallCli(): Promise<void> {
|
|
try {
|
|
const links = await call(commands.appCliUninstall());
|
|
notifications().notify({
|
|
level: "info",
|
|
title: tx(links.length ? "The openidea command is uninstalled" : "The openidea command is not installed"),
|
|
body: links.join("\n") || undefined,
|
|
key: KEY,
|
|
});
|
|
} catch (e) {
|
|
if (!isCancelled(e))
|
|
notifications().notify({
|
|
level: "error",
|
|
title: tx("Cannot uninstall the openidea command"),
|
|
body: errorText(e),
|
|
key: KEY,
|
|
});
|
|
}
|
|
}
|
|
|
|
export function cliActions(): Action[] {
|
|
return [
|
|
{
|
|
id: "app.installCli",
|
|
title: tx("Install 'openidea' Command"),
|
|
category: tx("Tools"),
|
|
keywords: ["cli", "shell", "terminal", "path", "command line", "launcher"],
|
|
run: installCli,
|
|
},
|
|
{
|
|
id: "app.uninstallCli",
|
|
title: tx("Uninstall 'openidea' Command"),
|
|
category: tx("Tools"),
|
|
keywords: ["cli", "shell", "terminal", "path", "command line", "launcher"],
|
|
run: uninstallCli,
|
|
},
|
|
];
|
|
}
|