Skip to content

mossaic-art takes --png in every mode and writes the file in only one of them #85

Description

@vyncint

Today

$ rm -f nope.png; mossaic-art --template dragon --year 2027 --png ./nope.png --no-colour --plan /dev/null >/dev/null 2>tmpl.err
template: exit=0 stderr=[] file=ls: nope.png: No such file or directory

$ rm -f m.png; mossaic-art VYNCINT --year 2027 --png ./m.png --no-colour --plan /dev/null
VYNCINT  ·  2027  ·  41 of 53 columns  ·  75 days  ·  300 commits
   … (the ordinary calendar report) …
exit=0
$ ls -l m.png
ls: m.png: No such file or directory

--list-templates, --track --merge … and --backfill --repo … behave the same: exit 0, empty stderr, no file. One mode writes it:

$ rm -f yes.png; mossaic-art --font --png ./yes.png --no-colour
wrote ./yes.png — 1674x836 px, 76 glyphs
exit=0

The neighbouring flags of the same shape are all refused, loudly:

mossaic-art: --invert describes how to read an image — it needs --image        exit=2
mossaic-art: --dither describes how to read an image — it needs --image        exit=2
mossaic-art: --track reports on the plan and writes nothing, so --snapshot would do nothing. Drop one of them.   exit=2

Why it is worth fixing--help documents --png PATH as "with --font, write the glyph sheet to a PNG instead", so the flag has exactly one valid companion, and every other flag in this binary that names a companion either honours it or refuses the combination. Issue #26 settled the principle in the maintainer's own words: "They are side effects and inputs the user explicitly asked for … Either honour them or refuse the combination." It enumerated --snapshot, --write and --file, all three of which are now refused, and missed this one. It is not #29 either — that was a zero-width PNG reported as success, closed at 0.4.0.

The cost is the shape a script cannot see. mossaic-art --template dragon --year 2027 --png preview.png in a workflow prints a cheerful report, exits 0 and produces nothing; the next step reads a file that is not there, or — in a job that regenerates art — silently republishes last run's stale PNG. The README teaches --png as the escape hatch for "any terminal at all", which is true of the chart binary, so pointing it at the picture you just previewed is the obvious next keystroke. Nothing in CI notices: install.yml only ever runs mossaic-art --font --png, the one combination that works.

Fix — refuse it. One line beside the existing --invert/--dither guards in src/bin/mossaic-art.rs: mossaic-art: --png writes the glyph sheet — it needs --font. Honouring it is the other option and is not cheap — it means deciding what a PNG of a preview, a template list, a tracking report and a backfill each are, and --snapshot plus mossaic --file --png already covers the one people actually want. Refusing keeps that door open.

Two adjacent silent no-ops belong in the same pass, both confirmed: -o ./out.art without --draw writes nothing and exits 0, and --format json without --track prints a human report and exits 0, which a | jq pipeline chokes on with no explanation.

Done whenmossaic-art --template dragon --year 2027 --png out.png exits non-zero with a message naming --font and writes no file, and the same for --matrix, --image, bare TEXT, --list-templates, --track and --backfill; mossaic-art --font --png out.png is unchanged; -o without --draw and --format json without --track are refused too; and tests/art_cli.rs asserts the refusal for at least the picture and the tracking mode, beside the existing --invert-without---image assertions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions