Skip to content

Commit d7e47d4

Browse files
committed
Improve install command
-> converge the command with the tools install command -> imoprove help
1 parent 133b8fa commit d7e47d4

File tree

3 files changed

+45
-22
lines changed

3 files changed

+45
-22
lines changed

src/command/install/cmd.ts

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,61 @@ import { Command } from "cliffy/command/mod.ts";
88
import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts";
99
import { createTempContext } from "../../core/temp.ts";
1010
import { installExtension } from "../../extension/install.ts";
11+
import { installTool } from "../tools/tools.ts";
12+
13+
import { info } from "log/mod.ts";
1114

1215
export const installCommand = new Command()
13-
.hidden() // TODO: unhide when ready
16+
.hidden()
1417
.name("install")
1518
.arguments("[target:string]")
19+
.arguments("<type:string> <target:string>")
1620
.option(
1721
"--no-prompt",
18-
"Do not prompt to confirm installation extension",
22+
"Do not prompt to confirm actions during installation",
1923
)
2024
.description(
21-
"Installs a Quarto Extension into the current directory or Project directory.",
25+
"Installs an extension or global dependency.",
2226
)
2327
.example(
24-
"Install extension from file",
25-
"quarto install /Users/catmemes/tools/my-extension.tar.gz",
28+
"Install extension from Github",
29+
"quarto install extension <gh-organization>/<gh-repo>",
2630
)
2731
.example(
28-
"Install extension from folder",
29-
"quarto install /Users/catmemes/tools/my-extension/",
32+
"Install extension from file",
33+
"quarto install extension tools/my-extension.tar.gz",
3034
)
3135
.example(
3236
"Install extension from url",
33-
"quarto install https://github.com/quarto-dev/quarto-extensions/releases/download/latest/my-extension.tar.gz",
37+
"quarto install extension <url>",
38+
)
39+
.example(
40+
"Install TinyTeX",
41+
"quarto install tool tinytex",
42+
)
43+
.example(
44+
"Install Chromium",
45+
"quarto install tool chromium",
3446
)
35-
.action(async (options: { prompt?: boolean }, target?: string) => {
36-
await initYamlIntelligenceResourcesFromFilesystem();
37-
const temp = createTempContext();
38-
try {
39-
if (target) {
40-
await installExtension(target, temp, options.prompt !== false);
47+
.action(
48+
async (options: { prompt?: boolean }, type: string, target: string) => {
49+
await initYamlIntelligenceResourcesFromFilesystem();
50+
const temp = createTempContext();
51+
try {
52+
if (type.toLowerCase() === "extension") {
53+
// Install an extension
54+
await installExtension(target, temp, options.prompt !== false);
55+
} else if (type.toLowerCase() === "tool") {
56+
// Install a tool
57+
await installTool(target);
58+
} else {
59+
// This is an unrecognized type option
60+
info(
61+
`Unrecorgnized option '${type}' - please choose 'tool' or 'extension'.`,
62+
);
63+
}
64+
} finally {
65+
temp.cleanup();
4166
}
42-
} finally {
43-
temp.cleanup();
44-
}
45-
});
67+
},
68+
);

src/command/tools/tools.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export async function installTool(name: string) {
116116
`Could not install '${name}'- try again with one of the following:`,
117117
);
118118
installableTools().forEach((name) =>
119-
info("quarto install " + name, { indent: 2 })
119+
info("quarto install tool " + name, { indent: 2 })
120120
);
121121
}
122122
}
@@ -143,7 +143,7 @@ export async function uninstallTool(name: string) {
143143
}
144144
} else {
145145
info(
146-
`${name} is not installed Use 'quarto install ${name} to install it.`,
146+
`${name} is not installed Use 'quarto install tool ${name} to install it.`,
147147
);
148148
}
149149
}

tests/smoke/extensions/install.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ inInstallDir(() => {
4141
// Verify installation using a remote github repo
4242
testQuartoCmd(
4343
"install",
44-
["dragonstyle/test-ext", "--no-prompt"],
44+
["extension", "dragonstyle/test-ext", "--no-prompt"],
4545
[noErrorsOrWarnings, verifySubDirCount("_extensions", 1)],
4646
{
4747
teardown: () => {
@@ -63,7 +63,7 @@ inInstallDir(() => {
6363
const zipPath = join(testDirAbs, "ext-repo", zipFile.path);
6464
testQuartoCmd(
6565
"install",
66-
[zipPath, "--no-prompt"],
66+
["extension", zipPath, "--no-prompt"],
6767
[noErrorsOrWarnings, verifySubDirCount("_extensions", zipFile.count)],
6868
{
6969
teardown: () => {

0 commit comments

Comments
 (0)