Add -mime GLOB: media-type predicate by extension (#90) - #219
Merged
Conversation
-mime GLOB matches the entry's media (MIME) type -- derived from its extension via a curated static table in the new xff/mime module -- against a shell glob, so -mime 'image/*' selects png/jpeg/gif/... at once, and -mime image/png the exact type. Extension-based, no libmagic dependency (per the no-heavyweight-native-deps rule); an unknown or absent extension is application/octet-stream (the file(1) fallback). Name-based and cheap (no content read, no -type gate) -- combine with -type f for regular files only. xff extension (find style rejects it). xff/mime: TypeForName(name) over a constexpr LimitedMap of ~44 common IANA-registered types (image/audio/video/text/application/font); source-code extensions are left out (language classification is #89). EvalMime globs it with fnmatch, like -type/-name. Self-doc: registry descriptor + kHelpText + design.md. Tests: mime_test (table: known/case-insensitive/compound/unknown/dotfile), evaluate_test (glob + octet-stream fallback), run_test e2e. bazel test //... green (40); both clang-format versions clean.
helly25
enabled auto-merge (squash)
July 3, 2026 00:33
helly25
added a commit
that referenced
this pull request
Jul 6, 2026
Remove five stale 'to do' bullets that describe already-implemented work, so TODO.md stops listing done features as open: - Right align numbers in summary -> shipped (#202, #235) - More output control for summary -> shipped (#86, #203, #275) - Align outputs like -ls -> shipped (#205, #206, #207) - Mimetype support -> shipped (#219 -mime) - File type support -> shipped (#262 -lang, #89) Fix the 'Color support' cross-reference that pointed at the removed 'File type support' bullet to name -lang / {lang} / languages.yml directly. Genuinely-open items (Line count {lines} field, per-file hashes, --sort/-j CLI test, histograms #81) are untouched.
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.
#90.
-mime GLOBmatches the entry's media (MIME) type - derived from its extension - against a shell glob.xff/mimemodule:TypeForName(name)over a constexprLimitedMapof ~44 common IANA-registered types (image/audio/video/text/application/font). Extension-based, no libmagic dependency (per the no-heavyweight-native-deps rule). Unknown/absent extension ->application/octet-stream(thefile(1)fallback). Source-code extensions are deliberately omitted (language classification is feat(config): .xffrc grammar parser (config phase B1) #89).EvalMimeglobs the type withfnmatch(like-type/-name). Name-based and cheap (no content read, no-typegate) - combine with-type ffor regular files. xff extension (--config=findrejects it).Self-doc: registry descriptor +
kHelpText+ design.md. Tests: mime_test (known / case-insensitive / compound / unknown / dotfile), evaluate_test (glob + octet-stream fallback), run_test e2e.bazel test //...green (40); both clang-format versions clean.A content-sniffing backend can layer on later; for now the extension map is the fast, dependency-free first cut.