Repository navigation
Report, fmt and management commands - #36
Merged
Merged
Conversation
… provenance Each view of a script is now a command that writes one thing to stdout. They read scripts as run does, with the catalog and -i inputs, through one loop (ScriptRunner) that takes each script through its session, its inputs and analysis and hands it to the command's view; run's rows are one such view. - check: nothing on stdout, diagnostics on stderr, exit 0 or 3, so `find … | xargs relix check` is a lint pass. --json writes every script's diagnostics as one document instead. - explain: each query's physical plan; --json writes one object per query per line. - optimize: the script with each query statement replaced by its rewritten query, every other statement and comment kept as written, so it works as a filter. A rewrite the engine cannot render as Relix that parses back is left as written, with a warning. --report prints the rules and the trees. - trace: the event feed of each query, rows discarded, each query's feed ending in a ROWS event. - bundle: the playground's JSON bundle, still produced for a script that does not analyse. - ir: the IR report of the whole script. - provenance: annotated rows, --semiring and --weight; a table on a terminal and JSON in a pipe. `run --trace[=FILE]` writes the event feed to stderr, or FILE, while the rows go to stdout. A file is named only with `=`, so `relix --trace q.relix` traces q.relix rather than writing over it. The example scripts the tests run every command over are in src/test/resources/examples. Part of #11.
`relix fmt [SCRIPT...]` prints each script with the engine's statement printer, the one behind Relix.definitions(), and standard input when no file is named. `-w` rewrites the files that change in place, and `--check` changes nothing, names each file that would change, and exits 1 if any would. `--glyphs` (the default) and `--keywords` choose the operator spelling. The keyword spelling is read from the reference's spellings page. The printer drops comments, and DarkCollective/relix-core#99 asks for that and the spelling choice in the engine. Until then fmt keeps them itself: - a comment between statements stays where it was, on its own line or after the statement it followed; - a statement with a comment inside it is left exactly as written; - blank lines between things collapse to one. The comments are found by ScriptText's scan, which follows the language's two lexers: `--` and `/* */` outside strings, and only at the start of a line inside an inline table, whose rule and cells may hold `--`. Inline tables' columns are aligned. A script that does not parse is reported as FILE:LINE:COL, left alone, and the run exits 3. Over every example script, fmt is idempotent, parses back to the same statements in either spelling, and keeps every comment in order. Part of #12.
… completion - `drivers ls` lists the JDBC drivers relix can install, with each one's scheme and whether it is installed. `drivers install NAME` downloads and installs one. Together they replace the run-time --download-drivers. - `connectors ls` lists the connectors installed, and `--available` adds the ones the hosted catalog offers. `connectors install TYPE` installs one. - `doc [TOPIC]` shows a reference page, found by glyph, keyword or name, rendered for a terminal and paged through $PAGER on one. `--markdown` prints the page as it is. With no topic it lists the pages as rows. A language keyword keeps a name it shares with a function (`doc fix` is the operator), and `--function` finds the function. - `help [COMMAND]` is picocli's, and `version` prints the front-end and engine versions. - `completion bash|zsh|fish|powershell` prints a completion script built from the command model. bash's is picocli's, which runs under zsh too. fish and PowerShell get theirs here. The listings print through the run's renderers. The index doc looks pages up in is built here, over relix-docs' language pages and the installed functions' pages, until DarkCollective/relix-core#95 puts it in relix-docs. It holds every key of relix-console's index except the REPL's page about itself. Each completion script is syntax-checked by its shell when that shell is installed. CI installs zsh and fish on Linux for this; the runners already have bash and PowerShell. Part of #13.
…ersion, completion relix version printed its line with \n, and --version with the platform's line separator, so on Windows the two differed. version now prints through the same version help.
…le, ir, provenance pokemon.relix read its data from PokeAPI over HTTP, so the tests over it failed whenever the service did (macOS CI: EOF reached while reading). The examples are now the three that need nothing but themselves, a test holds them to that, and introspection.relix's closure query covers a rewrite render() cannot write back.
This was referenced Oct 8, 2026
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.
Part of #17. Design:
docs/design.md§3, §4. One commit per issue.Report commands (#11)
ScriptRunner. It takes each script through its session, the catalog, the-iinputs and analysis, then hands it to the command's view.run's rows are one view, nowResultRows; each report command is another.check: nothing on stdout, diagnostics on stderr, exit 0 or 3, sofind … | xargs relix checkis a lint pass.--jsonwrites every script's diagnostics as one document on stdout instead.explain: each query's physical plan. A script with several queries heads each plan with-- query NAME.--jsonwrites one{"script", "query", "plan"}object per line.optimize: the script with eachquerystatement replaced byquery { <rewritten> };. Every other statement and comment is kept as written, sorelix optimize slow.relix > fast.relixworks.--reportprints the rules and the before/after trees instead.trace: each query's event feed, rows pulled and discarded. Each query's feed ends with aROWSevent.bundle: the playground JSON bundle, still produced for a script that doesn't analyse (with its diagnostics, exit 3).ir: the IR report of the whole script.provenance: annotated rows with--semiring(defaultcounting) and--weight. A[prov]table on a terminal, JSON in a pipe, or chosen with-o table|json.run --trace[=FILE]writes the event feed to stderr, or FILE, while the rows go to stdout. A file is named only with=:Maingives a bare--tracean empty value, sorelix --trace q.relixtracesq.relixrather than writing over it.explain,traceandprovenancetake--query=NAME.Engine bug found:
Relation.render()writes an optimisedCLOSUREwith its pushed-down seed in⟨…⟩, which the parser can't read back (the closure query inintrospection.relix).optimizechecks that each rewrite parses. One that doesn't is left as written, with a warning, so the output always runs. Filed as DarkCollective/relix-core#100.fmt (#12)
relix fmt [SCRIPT...]prints withScriptPrinter.-wrewrites the files that change.--checkchanges nothing, names the files that would change, and exits 1 if any would.--glyphs(the default) or--keywordspicks the operator spelling; the keyword spelling comes from the reference'slanguage/spellings.md.ScriptTextfinds statement ends and comments. It follows the two lexers:--and/* */outside strings, and inside an inline table only at the start of a line, because a cell or the|---|rule can hold--. Inline tables' columns are aligned.FILE:LINE:COL, left alone, and exits 3.Management commands (#13)
drivers ls/drivers install NAMEandconnectors ls [--available]/connectors install TYPE. They replace the run-time download flags;--allow-downloadstays for fetching during a run. Listings print through the S2 renderers. Messages go to stderr, and a failed download exits 5.doc [TOPIC]: a page found by glyph, keyword or name, rendered and paged through$PAGER(defaultlesswithLESS=FRX) on a terminal.--markdownprints the source,--no-pagerskips the pager, and--functionsearches functions only. With no topic, it lists the pages as rows.DocIndex) is built here, over relix-docs' language pages and the installed functions, with the language keyword winning a shared name (fix).repl,relix-repl).help [COMMAND]is picocli'sHelpCommand.versionprints the same line as--version.completion bash|zsh|fish|powershellcomes from the command model. bash's is picocli'sAutoComplete, which runs under zsh throughbashcompinit. The fish and PowerShell scripts are generated here.Tests
src/test/resources/examples: three real scripts from the earlier command (comments, inline tables, views, several queries each). All are offline, and a test keeps them that way..gitattributeskeeps.relixfiles LF.ReportCommandsTest:-e/stdin sources;checkover several files asxargsruns it, and--json;optimizeoutput returns the same rows as the original, for every example;run --trace: rows on stdout and events on stderr in one run,--trace=FILE, and a bare--tracebefore a script.FmtTest, over every example:-w,--checkand parse-failure exit codes.ManagementCommandsTest,DocIndexTestandPagerTest:doc --markdownresolves every key of every language page;./gradlew clean buildpasses locally (macOS) at each commit.Fixes #11
Fixes #12
Fixes #13