feat: check short flags - #12
Merged
Merged
Conversation
Only --long forms were scanned, so every '-v' in generated content was a
silent pass. The last silent-pass class in the flag checker.
A single-letter short flag is unambiguous — it is that flag or nothing —
so an absent one is an error, the same as a long flag.
A longer single-dash token is NOT unambiguous, and this is where the
feature could easily have made the tool worse. '-xzf' may be a cluster of
three flags; '-name' may be a single-dash long option (find, java); '-j4'
may be a flag with an attached value. Each reading is tried against
--help — a cluster verifies when every letter is a known flag, an
attached value when the leading flag is known — and only if none verifies
is a finding emitted, as a WARNING rather than an error. An ambiguous
token is unverifiable, not refuted, which is the same rule the checker
already applies to a command with no --help. Splitting '-name' into four
letter flags that do not exist would have been the obvious way to get
this wrong.
A dash followed by digits is read as the value it almost always is, so
'--threshold -5' does not treat '-5' as a flag. The cost is that a
numeric short flag ('head -5') goes unchecked; the alternative
false-positives on every negative number in a command line.
Also fixes a latent bug the feature exposed: _flag_in_help bounded a
match on the trailing side only, so '-v' matched the tail of '--v' and
reported a flag the command does not have as verified. Both sides are now
bounded. The trailing bound already stopped '-v' matching inside
'--verbose'; this closes the leading side.
173 tests pass, coverage 97% (flags.py 100%), mutation score 82.0%
against a 75% gate.
silversurfer562
force-pushed
the
claude/short-flag-support
branch
from
August 11, 2026 20:03
c6dffc8 to
fe76f48
Compare
Promotes the short-flag work to a release. Additive feature -> minor bump. Two version sites (pyproject, __init__) plus the changelog promotion; the ruff>=0.4.0 dep floor and the historical corpus comment are deliberately left alone.
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.
Only
--longforms were scanned, so every-vin generated content was a silent pass. This is the last silent-pass class in the flag checker.The easy half
A single-letter short flag is unambiguous — it is that flag or nothing — so an absent one is an error, exactly like a long flag.
The half that could have made the tool worse
A longer single-dash token has several valid readings:
-xzftar)-namefind,java)-j4make)Each reading is tried against
--help— a cluster verifies when every letter is a known flag, an attached value when the leading flag is known. Only if none verifies is a finding emitted, and then as a warning, not an error: an ambiguous token is unverifiable, not refuted. That's the same rule the checker already applies to a command with no--help.Splitting
-nameinto four letter flags that don't exist would have been the obvious way to get this wrong, and it would have fired on everyfindexample in every doc.A dash followed by digits is not a flag.
--threshold -5reads-5as the value it almost always is. The cost is that a numeric short flag (head -5) goes unchecked; the alternative false-positives on every negative number in a command line. Documented as a known limitation.A latent bug the feature exposed
_flag_in_helpbounded a match on the trailing side only. The trailing bound already stopped-vmatching inside--verbose— but nothing stopped it matching the tail of--v, so a command whose help has only--vwould report-vas verified. Both sides are now bounded. Covered byevasion_short_flag_hiding_in_long_flag.Verification
flags.py100%ruff+blackcleanVersion left at 0.4.0 with the entry under
[Unreleased]; additive, so the next release is a 0.5.0 minor.🤖 Generated with Claude Code