-
Notifications
You must be signed in to change notification settings - Fork 434
Expand file tree
/
Copy pathcmd.ts
More file actions
70 lines (66 loc) · 1.79 KB
/
cmd.ts
File metadata and controls
70 lines (66 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* cmd.ts
*
* Copyright (C) 2021-2022 Posit Software, PBC
*/
import { Command } from "cliffy/command/mod.ts";
import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts";
import { info } from "../../deno_ral/log.ts";
import {
loadTools,
removeTool,
selectTool,
} from "../../tools/tools-console.ts";
import { installableToolNames } from "../../tools/tools.ts";
export const uninstallCommand = new Command()
.name("uninstall")
.arguments("[tool]")
.option(
"--no-prompt",
"Do not prompt to confirm actions",
)
.option(
"--update-path",
"Update system path when a tool is installed",
)
.description(
`Uninstalls a global dependency (${installableToolNames().join(", ")}).`,
)
.example(
"Uninstall TinyTeX",
"quarto uninstall tinytex",
)
.example(
"Uninstall Chrome Headless Shell",
"quarto uninstall chrome-headless-shell",
)
.example(
"Uninstall Chromium (legacy)",
"quarto uninstall chromium",
)
.action(
async (
options: { prompt?: boolean; updatePath?: boolean },
tool?: string,
) => {
await initYamlIntelligenceResourcesFromFilesystem();
// -- update path
if (tool) {
// Explicitly provided
await removeTool(tool, options.prompt, options.updatePath);
} else {
// Not provided, give the user a list to choose from
const allTools = await loadTools();
if (allTools.filter((tool) => tool.installed).length === 0) {
info("No tools are installed.");
} else {
// Select which tool should be installed
const toolTarget = await selectTool(allTools, "remove");
if (toolTarget) {
info("");
await removeTool(toolTarget);
}
}
}
},
);