Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Julia engine commands #11803

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/command/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { addCommand } from "./add/cmd.ts";
import { uninstallCommand } from "./uninstall/cmd.ts";
import { createCommand } from "./create/cmd.ts";
import { editorSupportCommand } from "./editor-support/cmd.ts";
import { engineCommand } from "../execute/engine.ts";

// deno-lint-ignore no-explicit-any
export function commands(): Command<any>[] {
Expand Down Expand Up @@ -57,5 +58,6 @@ export function commands(): Command<any>[] {
checkCommand,
buildJsCommand,
editorSupportCommand,
engineCommand,
];
}
57 changes: 57 additions & 0 deletions src/execute/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { pandocBuiltInFormats } from "../core/pandoc/pandoc-formats.ts";
import { gitignoreEntries } from "../project/project-gitignore.ts";
import { juliaEngine } from "./julia.ts";
import { ensureFileInformationCache } from "../project/project-shared.ts";
import { Command } from "cliffy/command/mod.ts";

const kEngines: Map<string, ExecutionEngine> = new Map();

Expand Down Expand Up @@ -238,3 +239,59 @@ export function projectIgnoreGlobs(dir: string) {
gitignoreEntries(dir).map((ignore) => `**/${ignore}**`),
);
}

// export async function engineCommand(
// args: string[],
// env?: Record<string, string>,
// ) {
// if (args.length === 0) {
// throw ("No engine name given");
// }
// const engineKey = args[0];
// const engine = kEngines.get(engineKey);
// if (engine === undefined) {
// throw (`No engine with the name \"${engineKey}\" is registered. Available engines are ${
// Array.from(kEngines.keys()).map((key) => `"${key}"`).join(", ")
// }`);
// }

// if (args.length < 2) {
// throw ("No engine command specified");
// }
// const commandName = args[1];

// const commandFunction = engine.commands?.[commandName];
// if (commandFunction === undefined) {
// throw (`No command with the name \"${commandName}\" is registered for the engine \"${engineKey}\".`);
// }
// await commandFunction(args.slice(2), env);

// Deno.exit(0);
// }

export const engineCommand = new Command()
.name("engine")
.description(
`Access functionality specific to quarto's different rendering engines.`,
)
.action(() => {
engineCommand.showHelp();
Deno.exit(1);
});

kEngines.forEach((engine, name) => {
if (engine.populateCommand) {
const engineSubcommand = new Command();
// fill in some default behavior for each engine command
engineSubcommand
.description(
`Access functionality specific to the ${name} rendering engine.`,
)
.action(() => {
engineSubcommand.showHelp();
Deno.exit(1);
});
engine.populateCommand(engineSubcommand);
engineCommand.command(name, engineSubcommand);
}
});
Loading
Loading