Repository navigation
fix(cli): consistent input, output and error handling across the CLIs - #286
Merged
Merged
Conversation
rvt-gltf and rvt-sheet take the model as a positional argument and write model.glb / model.svg next to it unless -o says otherwise, the form the README already showed but the binaries rejected; --src / --dst (and -s / -d) still work, and both refuse to overwrite their input. rvt-ifc, rvt-doc and rvt-elements stop returning anyhow errors from main (which printed the Debug "Error:" form): every CLI reports "error: <message>", names the file once, and exits 1. rvt-schema, rvt-history, rvt-corpus (and doctor), rvt-elem-table and rvt-capabilities accept --json for --format json, as a usage error when combined with --format. Piping any CLI into head no longer ends in "failed printing to stdout: Broken pipe" and a panic backtrace: rvt::cli::exit_quietly_on_broken_pipe turns exactly that panic into exit status 141 (what a shell reports for SIGPIPE) on Unix and Windows pipes and leaves every other panic alone. Every --help ends with worked examples, each run against the family corpus first.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_f6588aa5-5501-451a-857b-10537356c083) |
DrunkOnJava
enabled auto-merge (squash)
September 22, 2026 19:23
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
The 18 CLIs now take input, write output and report errors the same way: positional input with a sensible default output, one
error: <message>line that names the file,--jsoneverywhere a JSON format exists, worked examples in every--help, and no panic backtrace when output is piped intohead.Motivation
The CLIs grew one at a time and a first-time user trips over the seams:
rvt-gltf my-project.rvt -o out.glbandrvt-sheet my-project.rvt -o out.svg; both binaries rejected that and demanded--src/--dst.rvt-ifc,rvt-docandrvt-elementsreturnedanyhow::Resultfrommain, so failures printed Rust's Debug form (Error: …);rvt-gltfprintedrvt-gltf: open …; the resterror: ….--jsonon some tools and-f jsonon others.rvt-schema model.rfa --json | head(or any large output into a closed pipe) ended infailed printing to stdout: Broken pipeplus aRUST_BACKTRACEhint.Changes
rvt-gltf,rvt-sheet: positionalINPUT,-o/--outputdefaulting to the input with.glb/.svg;--src/-s(hidden) and--dst/-d(alias of--output) still work; refuse to overwrite the input.rvt-ifc,rvt-doc,rvt-elements:mainreturnsExitCodeand printserror: <message>(exit 1). Open errors name the file once (the path comes from the library since feat(metadata): read worksharing, last save and document identity, and inventory folders with rvt-info #284).--jsonshorthand onrvt-schema,rvt-history,rvt-corpus(+doctor),rvt-elem-table,rvt-capabilities; combining it with--formatis a usage error (exit 2).src/cli.rs(new):exit_quietly_on_broken_pipe()— a panic hook that turns exactlyprintln!'s closed-pipe panic (os error 32Unix,os error 232Windows) into exit 141 and leaves every other panic, including a full disk behind a redirect, to the default report. Called first in all 18mains. Safe code, no new dependency.--helpends with anExamples:block; each example was run against the phi-ag family corpus before being written down (that run caught one wrong example:rvt-write --dry-runstill needs--dst).rvt-history/rvt-elem-tabledocument their positionalFILE.Testing
tools/check-local.shwithRVT_SAMPLES_DIR: fmt, clippy -D warnings, rustdoc -D warnings; workspace tests 1,291 passed, 1 failed — the failure isrvt_ifc_diagnostics_cli::rvt_ifc_cli_strict_mode_fails_before_writing_ifc_but_keeps_diagnostics, which fails identically onmainand on the commit before feat(metadata): read worksharing, last save and document identity, and inventory folders with rvt-info #284 whenever the family corpus is present (it expects confidencescaffold, the 2024 sample now yieldstyped_no_geometry). CI never runs that file, so it went unnoticed; the follow-up PR fixes it together with the CI gap that hid it.cargo +1.85.0 check --profile ci --all-targets(MSRV)tests/cli_ergonomics.rs(7 tests): positional input + default output,-o, legacy--src/--dstand-s/-d, overwrite refusal, oneerror:line naming the missing file exactly once for five CLIs,--json==--format jsonand the clash is exit 2, every--helphas examples, closed stdout pipe exits 141 without "panicked" (corpus-gated)Audit-honesty checklist
Legal and contribution hygiene
CONTRIBUTING.md)CLEANROOM.md)Breaking changes
None for invocations: every previous flag still parses.
rvt-ifc,rvt-docandrvt-elementsprinterror: …instead ofError: …(exit code unchanged, 1).Screenshots or output samples
Related issues
None
Note
Low Risk
User-facing CLI parsing and error/pipe handling only; export and decode paths are untouched aside from clearer error messages.
Overview
Standardizes how the shipped binaries accept input, write output, report failures, and behave when stdout is closed early—without changing IFC, glTF, or SVG export logic.
rvt-gltfandrvt-sheetnow match the README: positional model path, defaultmodel.glb/model.svgbeside the input,-o, and hidden legacy--src/--dst(aliases still work). Sharedresolve_pathsrefuses to overwrite the input. Errors useerror: …instead of tool-prefixed lines.rvt-ifc,rvt-doc, andrvt-elementsreturnExitCodefrommainand print a singleerror: <message>(exit 1) instead of anyhow’sError:debug form.Several tools gain
--jsonas shorthand for--format json(conflicts with-f→ usage error exit 2). Every--helpadds anExamples:block.New
rvt::cli::exit_quietly_on_broken_pipe(insrc/cli.rs) is invoked first in all shippedmainfunctions so piping intoheadexits 141 without a broken-pipe panic; other panics are unchanged.tests/cli_ergonomics.rslocks in positional/legacy flags, overwrite refusal, error shape,--json, help examples, and the quiet pipe exit.Reviewed by Cursor Bugbot for commit 17b8896. Configure here.