@@ -40,6 +40,7 @@ import { Command } from "cliffy/command/mod.ts";
4040import { quartoAPI } from "../core/quarto-api.ts" ;
4141import { satisfies } from "semver/mod.ts" ;
4242import { quartoConfig } from "../core/quarto.ts" ;
43+ import { initializeProjectContextAndEngines } from "../command/command-utils.ts" ;
4344
4445const kEngines : Map < string , ExecutionEngineDiscovery > = new Map ( ) ;
4546
@@ -375,3 +376,42 @@ export function projectIgnoreGlobs(dir: string) {
375376 gitignoreEntries ( dir ) . map ( ( ignore ) => `**/${ ignore } **` ) ,
376377 ) ;
377378}
379+
380+ export const engineCommand = new Command ( )
381+ . name ( "engine" )
382+ . description (
383+ `Access functionality specific to quarto's different rendering engines.` ,
384+ )
385+ . stopEarly ( )
386+ . arguments ( "<engine-name:string> [args...:string]" )
387+ . action ( async ( options , engineName : string , ...args : string [ ] ) => {
388+ // Initialize project context and register external engines
389+ await initializeProjectContextAndEngines ( ) ;
390+
391+ // Get the engine (now includes external ones)
392+ const engine = executionEngine ( engineName ) ;
393+ if ( ! engine ) {
394+ console . error ( `Unknown engine: ${ engineName } ` ) ;
395+ console . error (
396+ `Available engines: ${
397+ executionEngines ( ) . map ( ( e ) => e . name ) . join ( ", " )
398+ } `,
399+ ) ;
400+ Deno . exit ( 1 ) ;
401+ }
402+
403+ if ( ! engine . populateCommand ) {
404+ console . error ( `Engine ${ engineName } does not support subcommands` ) ;
405+ Deno . exit ( 1 ) ;
406+ }
407+
408+ // Create temporary command and let engine populate it
409+ const engineSubcommand = new Command ( )
410+ . description (
411+ `Access functionality specific to the ${ engineName } rendering engine.` ,
412+ ) ;
413+ engine . populateCommand ( engineSubcommand ) ;
414+
415+ // Recursively parse remaining arguments
416+ await engineSubcommand . parse ( args ) ;
417+ } ) ;
0 commit comments