Repository navigation
Document the show flags that exist, and fix what -top claims to do. - #80
Merged
Merged
Conversation
printUsage listed only -debug. show had grown -no-meta, -top, -t and -tag since, and nothing tied the usage text to the flag set, so the text simply stopped being true. All five are documented now, in the usage text and in the README's CLI section. TestPrintUsageMatchesShowFlags keeps them in step. It enumerates the real flag set via a newShowFlagSet extracted from runShow, and fails in both directions: a registered flag the text omits, and a documented flag that no longer exists. Both are the same bug. The \b in the match matters -- without it the -tag line would count as documenting -t. -top's description was also wrong, in a way worth naming. It said "only show top-level elements", which reads as a change to the default output. It is not: plain show lists the top level and reports a sequence by item count without descending into it either way. What -top does is narrow the -t search to the top level, and without -t it does nothing at all. TestWriteShowTopLevel had been asserting the flag's behaviour against a nil tag filter, which takes the non-recursive path regardless -- so it passed just as well with topLevel unset, and had never checked the flag. That is how the wrong description survived. It now contrasts a filtered search with and without -top over four cases, and the two filtered ones expect opposite results. Verified against pydicom's rtplan.dcm rather than assumed: -t TreatmentMachineName finds the element inside BeamSequence, and with -top finds nothing. The README's examples are commands that were actually run; an earlier draft used CodeValue, which that file does not contain at all, so both halves returned zero matches and demonstrated nothing. Also drops `var _ = regexp.Compile` from dictionary.go. Its comment claimed it forced an init for the regexp import, which regexp has no need of; nothing else in the file used the package, so the import went too. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
printUsagelisted only-debug.showhad grown-no-meta,-top,-tand-tagsince, and nothing tied the usage text to the flag set, so the text simply stopped being true. All five are documented now, in the usage text and in the README's CLI section.Keeping it true
TestPrintUsageMatchesShowFlagsenumerates the real flag set — via anewShowFlagSetextracted fromrunShow, not a hand-maintained copy — and fails in both directions: a registered flag the text omits, and a documented flag that no longer exists. Both are the same bug.Each direction was confirmed to fail rather than assumed:
-tline, keep-tag-t is registered but printUsage does not document it-nopelineprintUsage documents -nope but no such flag is registeredThe first case is why the match uses
\b: without it, the-tagline would count as documenting-t.-topdid not do what it saidIts description was "only show top-level elements", which reads as a change to the default output. It is not. Plain
showlists the top level and reports a sequence by item count without descending into it either way. What-topdoes is narrow the-tsearch to the top level — and without-tit does nothing at all.TestWriteShowTopLevelhad been asserting the flag's behaviour against a nil tag filter, which takes the non-recursive path regardless. So it passed just as well withtopLevelunset, and had never actually checked the flag. That is how the wrong description survived. It now contrasts a filtered search with and without-topacross four cases, and the two filtered ones expect opposite results. Flipping onetopLevelback tofalsefails it, so it is not vacuous.Verified against pydicom's
rtplan.dcmrather than reasoned about:The README's examples are commands that were actually run. An earlier draft used
CodeValue, which that file does not contain at all — both halves returned zero matches and demonstrated nothing. ProbingparseShowTagsthe same way also turned up something worth documenting:PatientName,00080060and"(0008,0060)"all parse, but a bare0008,0060does not, so the README now says the comma form needs the parentheses.Also
Drops
var _ = regexp.Compilefromdictionary.go. Its comment claimed it forced an init for theregexpimport, whichregexphas no need of; nothing else in the file used the package, so the import went too.Gate
go build,go vet,staticcheck -checks=all(the exact CI invocation), gofmt,go test -count=1 -p 4 ./...andGOARCH=386 CGO_ENABLED=0 go test ./...— all clean, 7 packages ok on both architectures.🤖 Generated with Claude Code