Skip to content

dev-call cli-info - new command to produce JSON information of CLI options #12606

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

Merged
merged 4 commits into from
Apr 29, 2025
Merged
Changes from all commits
Commits
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: 1 addition & 1 deletion package/src/common/prepare-dist.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import { Configuration } from "../common/config.ts";
import { buildFilter } from "./package-filters.ts";
import { bundle } from "../util/deno.ts";
import { info } from "../../../src/deno_ral/log.ts";
import { buildAssets } from "../../../src/command/build-js/cmd.ts";
import { buildAssets } from "../../../src/command/dev-call/build-artifacts/cmd.ts";
import { initTreeSitter } from "../../../src/core/schema/deno-init-tree-sitter.ts";
import {
Dependency,
4 changes: 2 additions & 2 deletions src/command/command.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ import { typstCommand } from "./typst/cmd.ts";
import { capabilitiesCommand } from "./capabilities/cmd.ts";
import { checkCommand } from "./check/cmd.ts";
import { inspectCommand } from "./inspect/cmd.ts";
import { buildJsCommand } from "./build-js/cmd.ts";
import { installCommand } from "./install/cmd.ts";
import { updateCommand } from "./update/cmd.ts";
import { publishCommand } from "./publish/cmd.ts";
@@ -30,6 +29,7 @@ import { uninstallCommand } from "./uninstall/cmd.ts";
import { createCommand } from "./create/cmd.ts";
import { editorSupportCommand } from "./editor-support/cmd.ts";
import { callCommand } from "./call/cmd.ts";
import { devCallCommand } from "./dev-call/cmd.ts";

// deno-lint-ignore no-explicit-any
export function commands(): Command<any>[] {
@@ -56,8 +56,8 @@ export function commands(): Command<any>[] {
capabilitiesCommand,
inspectCommand,
checkCommand,
buildJsCommand,
editorSupportCommand,
callCommand,
devCallCommand,
];
}
Original file line number Diff line number Diff line change
@@ -10,17 +10,17 @@ import {
ESBuildAnalysis,
esbuildAnalyze,
esbuildCompile,
} from "../../core/esbuild.ts";
import { buildIntelligenceResources } from "../../core/schema/build-schema-file.ts";
import { formatResourcePath, resourcePath } from "../../core/resources.ts";
} from "../../../core/esbuild.ts";
import { buildIntelligenceResources } from "../../../core/schema/build-schema-file.ts";
import { formatResourcePath, resourcePath } from "../../../core/resources.ts";
import { simple } from "acorn/walk";
import { Parser } from "acorn/acorn";
import classFields from "acorn-class-fields";
import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts";
import { initYamlIntelligenceResourcesFromFilesystem } from "../../../core/schema/utils.ts";

// initialize language handlers
import "../../core/handlers/handlers.ts";
import { join } from "../../deno_ral/path.ts";
import "../../../core/handlers/handlers.ts";
import { join } from "../../../deno_ral/path.ts";

function ensureAllowableIDESyntax(src: string, filename: string) {
const ast = Parser.extend(classFields).parse(src, {
61 changes: 61 additions & 0 deletions src/command/dev-call/cmd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Command } from "cliffy/command/mod.ts";
import { quartoConfig } from "../../core/quarto.ts";
import { commands } from "../command.ts";
import { buildJsCommand } from "./build-artifacts/cmd.ts";

type CommandOptionInfo = {
name: string;
description: string;
args: [];
flags: string[];
equalsSign: boolean;
typeDefinition: string;
};

type CommandInfo = {
name: string;
description: string;
options: CommandOptionInfo[];
// arguments: string[];
// subcommands: CommandInfo[];
// aliases: string[];
examples: { name: string; description: string }[];
// flags: string[];
usage: string;
commands: CommandInfo[];
};

const generateCliInfoCommand = new Command()
.name("cli-info")
.description("Generate JSON information about the Quarto CLI.")
.action(async () => {
const output: Record<string, unknown> = {};
output["version"] = quartoConfig.version();
const commandsInfo: CommandInfo[] = [];
output["commands"] = commandsInfo;
// deno-lint-ignore no-explicit-any
const cmdAsJson = (cmd: any): CommandInfo => {
return {
name: cmd.getName(),
description: cmd.getDescription(),
options: cmd.getOptions(),
usage: cmd.getUsage(),
examples: cmd.getExamples(),
commands: cmd.getCommands().map(cmdAsJson),
};
};
output["commands"] = commands().map(cmdAsJson);
console.log(JSON.stringify(output, null, 2));
});

export const devCallCommand = new Command()
.name("dev-call")
.description(
"Access internals of Quarto - this command is not intended for general use.",
)
.action(() => {
devCallCommand.showHelp();
Deno.exit(1);
})
.command("cli-info", generateCliInfoCommand)
.command("build-artifacts", buildJsCommand);