feat(cli): add q2 get-config to print merged document config as JSON#259
Merged
Conversation
`q2 get-config <file> [yaml-path]` returns a document's effective configuration after Quarto 2's full metadata merge (_quarto.yml, directory _metadata.yml layers, frontmatter, and format.<fmt>.* flattening), so external tools don't have to reimplement Quarto's metadata-resolution semantics. Closes #256. - pampa::config_json: ConfigValue -> clean JSON projection (ProseMode::{Value,Pandoc}) + dot-path navigation with array indices. - pampa writers: write_inlines (qmd) and {inlines,blocks}_to_source_free_json (json) reuse the maintained writers and strip source-tracking keys. - quarto-core::get_config::merge_document_metadata runs [Parse, MetadataMerge] via the same MetadataMergeStage a render uses (one merge path) and returns ast.meta + ASTContext. - CLI subcommand with --to / --output {value,pandoc} / --strict / --compact. - Docs: docs/guide/get-config.qmd. Tests: 12 unit (pampa) + 4 integration (quarto-core) + 11 CLI e2e (quarto). Full workspace nextest green; cargo xtask verify (WASM/hub build) green. Plan: claude-notes/plans/2026-06-02-get-config-command.md bd-xoaic Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
q2 get-config, a CLI command that returns a document's effective configuration after Quarto 2's full metadata-merge semantics — project_quarto.yml, directory_metadata.ymllayers, document front matter, andformat.<fmt>.*flattening — as JSON. External tools (editors, linters, build wrappers) can read resolved config without reimplementing any of Quarto's resolution rules.Closes #256.
format.html.toc,authors.0.name) selects a value; a numeric segment indexes an array.null, exit 0 (or--strictto error).--topicks the format whoseformat.<fmt>.*block is flattened in (defaulthtml).--output valuerenders prose (e.g.title) as a Markdown string;--output pandocemits a self-contained, source-free Pandoc AST fragment.How it works
The merged metadata is the
ast.metaproduced at the document-profile checkpoint, so the command runs only[ParseDocumentStage, MetadataMergeStage]— the sameMetadataMergeStagea real render uses (one merge code path, no engines/filters/rendering). This keepsget-configconsistent with rendering and cheap.Examples
Changes
pampa::config_json—ConfigValue→ clean JSON projection (ProseMode::{Value, Pandoc}) + dot-path navigation with array indices.pampa::writers—qmd::write_inlines;json::{inlines,blocks}_to_source_free_json(reuse the maintained writers, strips/l/attrS).quarto-core::get_config::merge_document_metadata— runs the parse+merge prefix and returnsast.meta+ASTContext; re-exports the projection helpers so the CLI stays within thequarto-coreAPI.quarto get-configCLI subcommand.docs/guide/get-config.qmd.Tests
pampa), 4 integration (quarto-core), 11 CLI e2e driving the realq2binary (quarto).cargo nextest rungreen (9542 passed);cargo xtask verifygreen including the WASM/hub-client build (pampafeeds the WASM image).Open question for review
Default
--toishtml, matching render's actual default (render only supports native/html today and bails otherwise). Implementing "first declared format" now would makeget-configinconsistent with render; deferred until render honors it. See the plan (claude-notes/plans/2026-06-02-get-config-command.md) for the full design and decisions D1–D8.🤖 Generated with Claude Code