import { Command } from "cliffy/command/mod.ts";
import { executionEngine, executionEngines } from "../../execute/engine.ts";
import { initializeProjectContextAndEngines } from "../command-utils.ts";
export const engineCommand = new Command()
.name("engine")
.description(
`Access functionality specific to quarto's different rendering engines.`,
)
.stopEarly()
.arguments("<engine-name:string> [args...:string]")
.action(async (options, engineName: string, ...args: string[]) => {
await initializeProjectContextAndEngines();
const engine = executionEngine(engineName);
if (!engine) {
console.error(`Unknown engine: ${engineName}`);
console.error(
`Available engines: ${
executionEngines().map((e) => e.name).join(", ")
}`,
);
Deno.exit(1);
}
if (!engine.populateCommand) {
console.error(`Engine ${engineName} does not support subcommands`);
Deno.exit(1);
}
const engineSubcommand = new Command()
.description(
`Access functionality specific to the ${engineName} rendering engine.`,
);
engine.populateCommand(engineSubcommand);
await engineSubcommand.parse(args);
});