Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/src/command/use/cmd.ts
3584 views
1
/*
2
* cmd.ts
3
*
4
* Copyright (C) 2021-2022 Posit Software, PBC
5
*/
6
import { Command, ValidationError } from "cliffy/command/mod.ts";
7
8
import { useTemplateCommand } from "./commands/template.ts";
9
import { useBinderCommand } from "./commands/binder/binder.ts";
10
11
const kUseCommands = [useTemplateCommand, useBinderCommand];
12
13
export const makeUseCommand = () => {
14
const theCommand = new Command()
15
.name("use")
16
.arguments("<type:string> [target:string]")
17
.option(
18
"--no-prompt",
19
"Do not prompt to confirm actions",
20
)
21
.description(
22
"Automate document or project setup tasks.",
23
)
24
.action((_options, type, _target) => {
25
const useCommand = kUseCommands.find((command) => {
26
return command.getName() === type;
27
});
28
29
if (!useCommand) {
30
throw new ValidationError(
31
`Unknown type '${type}'- did you mean 'template'?`,
32
);
33
}
34
});
35
36
kUseCommands.forEach((command) => {
37
theCommand.command(command.getName(), command);
38
});
39
return theCommand;
40
};
41
42