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
3583 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
17
export const uninstallCommand = new Command()
18
.name("uninstall")
19
.arguments("[tool]")
20
.option(
21
"--no-prompt",
22
"Do not prompt to confirm actions",
23
)
24
.option(
25
"--update-path",
26
"Update system path when a tool is installed",
27
)
28
.description(
29
"Removes an extension.",
30
)
31
.example(
32
"Remove extension using name",
33
"quarto remove <extension-name>",
34
)
35
.action(
36
async (
37
options: { prompt?: boolean; updatePath?: boolean },
38
tool?: string,
39
) => {
40
await initYamlIntelligenceResourcesFromFilesystem();
41
42
// -- update path
43
if (tool) {
44
// Explicitly provided
45
await removeTool(tool, options.prompt, options.updatePath);
46
} else {
47
// Not provided, give the user a list to choose from
48
const allTools = await loadTools();
49
if (allTools.filter((tool) => tool.installed).length === 0) {
50
info("No tools are installed.");
51
} else {
52
// Select which tool should be installed
53
const toolTarget = await selectTool(allTools, "remove");
54
if (toolTarget) {
55
info("");
56
await removeTool(toolTarget);
57
}
58
}
59
}
60
},
61
);
62
63