Skip to content

The hyphen the font draws cannot start a text, and -- is rejected as an unknown option #92

Description

@vyncint

Today

$ for t in '-' '-.-' '-A'; do
>   mossaic-art "$t"    --year 2027 --no-colour --plan /dev/null; echo "  exit=$?"
>   mossaic-art -- "$t" --year 2027 --no-colour --plan /dev/null; echo "  exit=$? (with --)"
> done
mossaic-art: unknown option "-" — try --help
  exit=2
mossaic-art: unknown option "--" — try --help
  exit=2 (with --)
mossaic-art: unknown option "-.-" — try --help
  exit=2
mossaic-art: unknown option "--" — try --help
  exit=2 (with --)
mossaic-art: unknown option "-A" — try --help
  exit=2
mossaic-art: unknown option "--" — try --help
  exit=2 (with --)

The glyph plainly exists, and the tool advertises it:

$ mossaic-art 'A-B' --year 2027 --no-colour --plan /dev/null | head -1
A-B  ·  2027  ·  17 of 53 columns  ·  35 days  ·  140 commits
$ mossaic-art --font | head -1
77 glyphs, 5x5 each — write any of them with mossaic-art TEXT
$ mossaic-art 'é' --year 2027 … 2>&1 | head -1
mossaic-art: no glyph for: 'é' — the font has ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -.!?,'"+=<>()/\*_@&#% and space, …

The renderer is fine with it; only the command line cannot say it:

$ printf '{ "text": "-A-", "year": 2027, "start_week": 0, "top": 0, "commits": 4, "background": 0, "user": null }' > dashplan.json
$ mossaic-art --plan dashplan.json --no-colour | sed -n 2p
-A-  ·  2027  ·  17 of 53 columns  ·  23 days  ·  92 commits

The only workaround shifts the drawing by a column (' -' gives 11 of 53 columns), and the hole is in the shared parser, so the chart has it too:

$ mossaic -weirdlogin
mossaic: unknown option "-weirdlogin" — try --help
$ mossaic -- -weirdlogin
mossaic: unknown option "--" — try --help
$ grep -n '"--"' src/cli.rs
(no match — there is no bare `--` case; it falls through to the unknown-option arm)

Why it is worth fixing — the promise broken here is the project's own, not just POSIX convention. README.md:240-244 lists - first among the punctuation it says draws, action/action.yml:24 names it in the text: input description ("A-Z, 0-9, space, - and ."), and the binary's own no-glyph message prints it in the alphabet. A character the documentation lists three times cannot be typed in the position the documentation puts it in.

And it is a hole with no way out. The user reaches for -- because that is what -- is for, and gets the same error naming --; no quoting or escaping helps; the only route through is a hand-written plan JSON, which nothing documents. The error also misleads — it says the text is an option, so the reader hunts for a flag they mistyped rather than a parser limitation.

You reach for mossaic-art -- "$TEXT" precisely when the text is not yours to control. The Action passes user input straight into that slot (args=("${INPUT_TEXT}"), action/action.yml:295), so text: "-2027-" fails the whole job on unknown option "-2027-" — reconstructed by rebuilding that argument vector locally, since nothing in this repository executes action.yml.

Fix — treat a bare -- in Args as "everything after this is positional": set a flag when it is popped, and have each binary's loop take the remaining arguments as the TEXT or the username rather than matching them against option names. Two lines in src/cli.rs plus the positional arm in each of the two loops, and it fixes a dash-led login in the chart at the same time. Mention -- in --help's usage block on the TEXT line.

Do not guess in the other direction — "it looks like text, so treat it as text" would make a mistyped --yaer 2027 silently become a drawing. Sharpening the message is the right companion: when a leading-dash argument matches no known flag and no positional has been given yet, say mossaic-art: unknown option "-A-" — if that is the text, write it after --.

Done whenmossaic-art -- '-' draws the hyphen glyph at 5 of 53 columns and exits 0; mossaic-art -- '-VYNCINT-' draws nine glyphs; mossaic-art -- --year 2027 treats --year as text; mossaic-art -- -h draws rather than printing help; mossaic -- -weirdlogin treats the argument as a login; mossaic-art --wombat still exits 2 with unknown option, and a bare leading-dash argument before any -- still exits 2 but its message mentions --; and a cli.rs unit test plus a tests/art_cli.rs case cover -- followed by an argument that looks like an option, so the Action's input path has one assertion behind it.

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