Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/src/command/call/engine-cmd.ts
6458 views
1
/*
2
* engine-cmd.ts
3
*
4
* CLI command for accessing engine-specific functionality
5
*
6
* Copyright (C) 2020-2022 Posit Software, PBC
7
*/
8
9
import { Command } from "cliffy/command/mod.ts";
10
import { executionEngine, executionEngines } from "../../execute/engine.ts";
11
import { initializeProjectContextAndEngines } from "../command-utils.ts";
12
13
export const engineCommand = new Command()
14
.name("engine")
15
.description(
16
`Access functionality specific to quarto's different rendering engines.`,
17
)
18
.stopEarly()
19
.arguments("<engine-name:string> [args...:string]")
20
.action(async (options, engineName: string, ...args: string[]) => {
21
// Initialize project context and register external engines
22
await initializeProjectContextAndEngines();
23
24
// Get the engine (now includes external ones)
25
const engine = executionEngine(engineName);
26
if (!engine) {
27
console.error(`Unknown engine: ${engineName}`);
28
console.error(
29
`Available engines: ${
30
executionEngines().map((e) => e.name).join(", ")
31
}`,
32
);
33
Deno.exit(1);
34
}
35
36
if (!engine.populateCommand) {
37
console.error(`Engine ${engineName} does not support subcommands`);
38
Deno.exit(1);
39
}
40
41
// Create temporary command and let engine populate it
42
const engineSubcommand = new Command()
43
.description(
44
`Access functionality specific to the ${engineName} rendering engine.`,
45
);
46
engine.populateCommand(engineSubcommand);
47
48
// Recursively parse remaining arguments
49
await engineSubcommand.parse(args);
50
});
51
52