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