Skip to content

fix(cli): refuse a boolean flag's value that citty would not read - #223

Merged
neoromantic merged 1 commit into
neoromantic:mainfrom
ertembiyik:ertembiyik/NO-TASK/boolean-flag-values
Nov 19, 2026
Merged

neoromantic merged 1 commit into
neoromantic:mainfrom
ertembiyik:ertembiyik/NO-TASK/boolean-flag-values

Conversation

@ertembiyik

Copy link
Copy Markdown
Contributor

What and why

A follow-up to #220 (Refs #217). The args check refuses --silent false, but the same value written with = still gets through, and citty does not read it:

Written citty reads
--silent=no, --silent=0, --silent=, --silent=False --silent
--no-silent=false --no-silent
-q=false -q

So tg send --silent=no sends silently. The check now returns INVALID_ARGS (exit 3) for these before the command runs. --flag=true and --flag=false are read as written and still work, as do --no-flag=true and -q=true.

One more line in the same message: --no-silent false used to suggest --no-silent or --no-no-silent; it now names --silent or --no-silent.

tg api and tg sql are not checked, as before.

If this lands, the --revoke=<value> check in #190 becomes a duplicate and I will remove it there.

How I checked it

  • citty's reading of each form in the table: parseArgs run by hand on a boolean flag with a default and one with an alias.

  • src/utils/args.test.ts: six new cases, all failing on main before the change (--silent=no, --silent=0, --silent=, --no-silent=false, -q=false, and the message for --no-silent false). The case of accepted forms now also has --html=true beside --silent=false.

  • src/test/access.e2e.test.ts: tg send --to me -m hi --silent=no is INVALID_ARGS with exit 3 before connecting.

  • bun run check: clean. bun run test: 1212 pass, 0 fail. bun run test:e2e: 339 pass, 0 fail.

  • Tests pass locally and use made-up data only

  • README, docs and affected demos follow the product content standard (docs/api-design.md, CHANGELOG)

  • Title follows the repo's commit style: Conventional Commits (feat: …, fix: …) unless AGENTS.md says otherwise

🤖 Generated with Claude Code

citty reads --silent=no, --silent=0 and --silent= as --silent, drops the
value of --no-silent=false and reads -q=false as -q. The args check now
refuses these with INVALID_ARGS, as it does --silent false; --flag=true
and --flag=false still work. The message for a negated flag that got a
value names --silent and --no-silent, not --no-no-silent.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@neoromantic
neoromantic merged commit b5790e5 into neoromantic:main Nov 19, 2026
ertembiyik pushed a commit to ertembiyik/telegram-sync-cli that referenced this pull request Nov 20, 2026
0.15.0 is published, so the entry from neoromantic#223 moves out of its section.

Refs neoromantic#217

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants