Skip to content

Commit 8bfb57c

Browse files
committed
Stub in remove command
1 parent d7e47d4 commit 8bfb57c

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

src/command/command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { inspectCommand } from "./inspect/cmd.ts";
2121
import { buildJsCommand } from "./build-js/cmd.ts";
2222
import { installCommand } from "./install/cmd.ts";
2323
import { publishCommand } from "./publish/cmd.ts";
24+
import { removeCommand } from "./remove/cmd.ts";
2425

2526
// deno-lint-ignore no-explicit-any
2627
export function commands(): Command<any>[] {
@@ -33,6 +34,7 @@ export function commands(): Command<any>[] {
3334
pandocCommand,
3435
runCommand,
3536
installCommand,
37+
removeCommand,
3638
publishCommand,
3739
capabilitiesCommand,
3840
inspectCommand,

src/command/remove/cmd.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* cmd.ts
3+
*
4+
* Copyright (C) 2021 by RStudio, PBC
5+
*
6+
*/
7+
import { Command } from "cliffy/command/mod.ts";
8+
import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts";
9+
import { createTempContext } from "../../core/temp.ts";
10+
import { uninstallTool } from "../tools/tools.ts";
11+
12+
import { info } from "log/mod.ts";
13+
14+
export const removeCommand = new Command()
15+
.hidden()
16+
.name("remove")
17+
.arguments("[target:string]")
18+
.arguments("<type:string> <target:string>")
19+
.option(
20+
"--no-prompt",
21+
"Do not prompt to confirm actions during installation",
22+
)
23+
.description(
24+
"Removes an extension or global dependency.",
25+
)
26+
.example(
27+
"Remove extension using name",
28+
"quarto remove extension <extension-name>",
29+
)
30+
.example(
31+
"Remove TinyTeX",
32+
"quarto remove tool tinytex",
33+
)
34+
.example(
35+
"Remove Chromium",
36+
"quarto remove tool chromium",
37+
)
38+
.action(
39+
async (options: { prompt?: boolean }, type: string, target: string) => {
40+
await initYamlIntelligenceResourcesFromFilesystem();
41+
const temp = createTempContext();
42+
try {
43+
if (type.toLowerCase() === "extension") {
44+
// Install an extension
45+
// TODO: Remove extension
46+
} else if (type.toLowerCase() === "tool") {
47+
// Install a tool
48+
await uninstallTool(target);
49+
} else {
50+
// This is an unrecognized type option
51+
info(
52+
`Unrecorgnized option '${type}' - please choose 'tool' or 'extension'.`,
53+
);
54+
}
55+
} finally {
56+
temp.cleanup();
57+
}
58+
},
59+
);

0 commit comments

Comments
 (0)