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
6438 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
import { useBrandCommand } from "./commands/brand.ts";
11
12
const kUseCommands = [useTemplateCommand, useBinderCommand, useBrandCommand];
13
14
export const makeUseCommand = () => {
15
const theCommand = new Command()
16
.name("use")
17
.arguments("<type:string> [target:string]")
18
.option(
19
"--no-prompt",
20
"Do not prompt to confirm actions",
21
)
22
.description(
23
"Automate document or project setup tasks.",
24
)
25
.action((_options, type, _target) => {
26
const useCommand = kUseCommands.find((command) => {
27
return command.getName() === type;
28
});
29
30
if (!useCommand) {
31
throw new ValidationError(
32
`Unknown type '${type}'- did you mean 'template'?`,
33
);
34
}
35
});
36
37
kUseCommands.forEach((command) => {
38
theCommand.command(command.getName(), command);
39
});
40
return theCommand;
41
};
42
43