Emit a single parseable line for piped fj --version #115

Closed
opened 2026-06-11 00:08:49 +00:00 by stephen · 0 comments
Owner

Task

Make piped fj --version emit a single parseable line. Gate ErrorKind::DisplayVersion on std::io::stdout().is_terminal() exactly like the adjacent DisplayHelp branch already is (src/main.rs), so an interactive fj --version still wears the brand mark but a piped/redirected one emits just fj 0.2.0. (Alternative, if the mark on interactive --version is worth keeping: print the logo to stderr and the version line to stdout.)

Add a test asserting fj --version with a non-tty stdout produces a single line matching ^fj \d+\.\d+\.\d+$, mirroring the piped-help coverage.

Source: rasterstate/fj#105.

Priority

p3. A first-contact paper cut: version-probing is often the very first programmatic call a new adopter or agent makes (CI provenance, tool --version || install guards, self-checks), and fj --version | head -1 returns a blank line instead of the datum. Real scripting-reliability value, but trivially worked around (tail -1) and low-frequency, so it sits below the structural gaps.

Reason

The doc-comment on handle_parse_outcome (src/main.rs) promises piped-clean --version/--help, but the implementation honors it only for help: ErrorKind::DisplayVersion => true always prints the 15-line mark, while DisplayHelp is gated on is_terminal(). So fj --help | cat is clean but fj --version | cat is 16 lines with the real datum last and a leading blank. git --version and gh --version each emit exactly one line.

Acceptance

  • fj --version piped/redirected (non-tty stdout) emits exactly one line matching ^fj \d+\.\d+\.\d+$.
  • fj --version on an interactive tty keeps the brand mark (or routes it to stderr, decision recorded).
  • The handle_parse_outcome doc-comment matches the implemented behavior.
  • A test covers the non-tty single-line case, mirroring the piped-help test.
  • cargo fmt --check, cargo clippy --all-targets --all-features -- -D warnings, and cargo test --all pass.

Dependencies

None. Self-contained one-function change in src/main.rs plus a test.

Size

S

## Task Make piped `fj --version` emit a single parseable line. Gate `ErrorKind::DisplayVersion` on `std::io::stdout().is_terminal()` exactly like the adjacent `DisplayHelp` branch already is (`src/main.rs`), so an interactive `fj --version` still wears the brand mark but a piped/redirected one emits just `fj 0.2.0`. (Alternative, if the mark on interactive `--version` is worth keeping: print the logo to stderr and the version line to stdout.) Add a test asserting `fj --version` with a non-tty stdout produces a single line matching `^fj \d+\.\d+\.\d+$`, mirroring the piped-help coverage. Source: `rasterstate/fj#105`. ## Priority p3. A first-contact paper cut: version-probing is often the very first programmatic call a new adopter or agent makes (CI provenance, `tool --version || install` guards, self-checks), and `fj --version | head -1` returns a blank line instead of the datum. Real scripting-reliability value, but trivially worked around (`tail -1`) and low-frequency, so it sits below the structural gaps. ## Reason The doc-comment on `handle_parse_outcome` (`src/main.rs`) promises piped-clean `--version`/`--help`, but the implementation honors it only for help: `ErrorKind::DisplayVersion => true` always prints the 15-line mark, while `DisplayHelp` is gated on `is_terminal()`. So `fj --help | cat` is clean but `fj --version | cat` is 16 lines with the real datum last and a leading blank. `git --version` and `gh --version` each emit exactly one line. ## Acceptance - [ ] `fj --version` piped/redirected (non-tty stdout) emits exactly one line matching `^fj \d+\.\d+\.\d+$`. - [ ] `fj --version` on an interactive tty keeps the brand mark (or routes it to stderr, decision recorded). - [ ] The `handle_parse_outcome` doc-comment matches the implemented behavior. - [ ] A test covers the non-tty single-line case, mirroring the piped-help test. - [ ] `cargo fmt --check`, `cargo clippy --all-targets --all-features -- -D warnings`, and `cargo test --all` pass. ## Dependencies None. Self-contained one-function change in `src/main.rs` plus a test. ## Size S
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rasterstate/fj#115
No description provided.