-
Notifications
You must be signed in to change notification settings - Fork 433
Expand file tree
/
Copy pathcmd.ts
More file actions
66 lines (64 loc) · 1.69 KB
/
cmd.ts
File metadata and controls
66 lines (64 loc) · 1.69 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
/*
* cmd.ts
*
* Copyright (C) 2021-2022 Posit Software, PBC
*/
import { Command } from "cliffy/command/mod.ts";
import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts";
import { createTempContext } from "../../core/temp.ts";
import { installExtension } from "../../extension/install.ts";
import { info } from "../../deno_ral/log.ts";
import { signalCommandFailure } from "../utils.ts";
export const addCommand = new Command()
.name("add")
.arguments("<extension:string>")
.option(
"--no-prompt",
"Do not prompt to confirm actions",
)
.option(
"--embed <extensionId>",
"Embed this extension within another extension (used when authoring extensions).",
)
.description(
"Add an extension to this folder or project",
)
.example(
"Install extension (Github)",
"quarto add <gh-org>/<gh-repo>",
)
.example(
"Install extension (file)",
"quarto add <path-to-zip>",
)
.example(
"Install extension (url)",
"quarto add <url>",
)
.action(
async (
options: { prompt?: boolean; embed?: string; updatePath?: boolean },
extension: string,
) => {
await initYamlIntelligenceResourcesFromFilesystem();
const temp = createTempContext();
try {
if (!extension) {
info("Please provide an extension name, url, or path.");
signalCommandFailure();
}
// Install an extension
const result = await installExtension(
extension,
temp,
options.prompt !== false,
options.embed,
);
if (!result) {
signalCommandFailure();
}
} finally {
temp.cleanup();
}
},
);