Skip to content

Commit f36f1ab

Browse files
committed
Add advanced filtering features to view command
Implements four powerful new features for the view command: - Count-only mode (--count): Show only match count without details - Comments search: Extended --search-in with 'comments' and 'all' options - Status filtering (--status): Filter by translation completeness (empty/missing/untranslated/complete/partial) - Inverse matching (--not): Exclude keys matching patterns (supports multiple flags or comma-separated) Changes: - Extended SearchScope enum with Comments and All values - Added TranslationStatus enum with 5 status types - Added DisplayCount(), FilterByStatus(), and ApplyExclusions() helper methods - Reorganized filter pipeline: Pattern → Culture → Status → Exclusions → Limit → Display/Count - Added 16 comprehensive unit tests (153 total tests passing) - Updated COMMANDS.md with detailed examples for all new features - Updated README.md with quick start examples
1 parent 640546c commit f36f1ab

4 files changed

Lines changed: 849 additions & 22 deletions

File tree

COMMANDS.md

Lines changed: 157 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,11 @@ Summary Table:
156156
- `--config-file <PATH>` - Path to configuration file
157157
- `-f, --format <FORMAT>` - Output format: `table` (default), `json`, or `simple`
158158
- `--regex` - Treat KEY as a regular expression pattern
159-
- `--search-in|--scope <SCOPE>` - Where to search: `keys` (default), `values`, or `both`
159+
- `--search-in|--scope <SCOPE>` - Where to search: `keys` (default), `values`, `both`, `comments`, or `all`
160160
- `--case-sensitive` - Make search case-sensitive (default is case-insensitive)
161+
- `--count` - Show only the count of matching keys (no details)
162+
- `--status <STATUS>` - Filter by translation status: `empty`, `missing`, `untranslated`, `complete`, or `partial`
163+
- `--not <PATTERNS>` - Exclude keys matching these patterns (comma-separated, supports wildcards)
161164
- `--show-comments` - Include comments in output
162165
- `--limit <COUNT>` - Maximum number of keys to display (default: 100, 0 for no limit)
163166
- `--no-limit` - Show all matches without limit (same as --limit 0)
@@ -309,6 +312,14 @@ lrm view "Introuvable" --search-in values --cultures fr
309312
lrm view "Cancel" --search-in both
310313
# Returns key if EITHER key name OR any translation matches
311314

315+
# Search in comments only
316+
lrm view "*deprecated*" --search-in comments
317+
# Find all keys with "deprecated" in comments
318+
319+
# Search everywhere (keys, values, AND comments)
320+
lrm view "password" --search-in all
321+
# Find "password" in any location
322+
312323
# Combine with wildcards
313324
lrm view "*error*" --search-in values
314325
# Find all keys with values containing "error"
@@ -325,6 +336,10 @@ lrm view "Save" --search-in values --cultures fr
325336
lrm view "contact support" --search-in values --format json
326337
# Find all keys mentioning "contact support" in any language
327338

339+
# Find keys with specific context/comments
340+
lrm view "*navigation*" --search-in comments
341+
# Find keys with navigation-related comments
342+
328343
# Use alias --scope
329344
lrm view "Button" --scope both
330345
```
@@ -333,9 +348,150 @@ lrm view "Button" --scope both
333348
- `--search-in keys` (default): Searches key names only (backward compatible)
334349
- `--search-in values`: Searches translation values across ALL languages
335350
- `--search-in both`: Matches if key OR any value matches
351+
- `--search-in comments`: Searches comments across ALL languages
352+
- `--search-in all`: Searches keys, values, AND comments everywhere
336353
- `--cultures` affects display, not search scope - all languages are still searched
337354
- Searches are **case-insensitive by default** - use `--case-sensitive` to enable exact case matching
338355

356+
**Count-Only Mode:**
357+
358+
Get just the count of matching keys without displaying details using `--count`:
359+
360+
```bash
361+
# Count all Error keys
362+
lrm view "Error.*" --count
363+
# Output: Pattern: Error.* (wildcard)
364+
# Found 15 matching key(s)
365+
366+
# Count with JSON output for automation
367+
lrm view "Button.*" --count --format json
368+
# Output: {"pattern":"Button.*","patternType":"wildcard","matchCount":8}
369+
370+
# Count complete translations
371+
lrm view "*" --status complete --count
372+
# Output: Found 42 matching key(s)
373+
374+
# Count with multiple filters
375+
lrm view "*" --cultures fr --status untranslated --count
376+
# Output: Found 12 matching key(s)
377+
```
378+
379+
**Status Filtering:**
380+
381+
Filter keys by their translation completeness using `--status`:
382+
383+
```bash
384+
# Find keys with empty values in any language
385+
lrm view "*" --status empty
386+
# Shows keys where at least one language has empty/whitespace value
387+
388+
# Find keys missing from any language file
389+
lrm view "*" --status missing
390+
# Shows keys that don't exist in one or more language files
391+
392+
# Find untranslated keys (empty, missing, or same as default)
393+
lrm view "*" --status untranslated
394+
# Shows keys needing translation work
395+
396+
# Find fully translated keys
397+
lrm view "*" --status complete
398+
# Shows keys with non-empty values in all languages
399+
400+
# Find partially translated keys
401+
lrm view "*" --status partial
402+
# Shows keys with some but not all translations
403+
404+
# Combine with pattern matching
405+
lrm view "Error.*" --status untranslated
406+
# Find untranslated Error keys
407+
408+
# Check specific language
409+
lrm view "*" --cultures fr --status untranslated
410+
# Find keys untranslated in French only
411+
412+
# Export for translators
413+
lrm view "*" --status partial --format json --limit 0
414+
# Get all partially translated keys as JSON
415+
416+
# Count untranslated keys
417+
lrm view "*" --status untranslated --count
418+
# Quick summary of translation work needed
419+
```
420+
421+
**Status Types:**
422+
- `empty`: Keys with empty/whitespace values in any language
423+
- `missing`: Keys absent from any language file
424+
- `untranslated`: Keys that are empty, missing, OR identical to default value
425+
- `complete`: Keys with non-empty translations in all languages
426+
- `partial`: Keys with some but not all translations
427+
428+
**Note:** When using `--cultures` with `--status`, the status check applies only to the filtered languages. For example, `--cultures fr --status untranslated` finds keys untranslated in French only, not all languages.
429+
430+
**Inverse Matching (Exclusions):**
431+
432+
Exclude keys matching specific patterns using `--not`:
433+
434+
```bash
435+
# Exclude specific key
436+
lrm view "Button.*" --not Button.Cancel
437+
# Shows all Button keys except Cancel
438+
439+
# Exclude with wildcards
440+
lrm view "*" --not "Test.*" --limit 50
441+
# Show first 50 keys, excluding all Test keys
442+
443+
# Multiple exclusion patterns (comma-separated)
444+
lrm view "*" --not "Button.*,Link.*,Icon.*"
445+
# Exclude multiple namespaces
446+
447+
# Multiple exclusion patterns (multiple flags - recommended for shell safety)
448+
lrm view "*" --not "Button.*" --not "Link.*" --not "Icon.*"
449+
# Same as above, but cleaner syntax
450+
451+
# Combine with other filters
452+
lrm view "*" --status untranslated --not "Debug.*" --not "Test.*"
453+
# Find untranslated keys, excluding debug/test keys
454+
455+
# Complex filtering (multiple flags)
456+
lrm view "App.*" --not "App.Internal.*" --not "App.Debug.*"
457+
# Show App keys except internal and debug
458+
459+
# Complex filtering (comma-separated - needs quotes)
460+
lrm view "App.*" --not "App.Internal.*,App.Debug.*"
461+
# Same as above, comma-separated (must quote the whole string)
462+
463+
# Case-insensitive by default
464+
lrm view "*" --not "BUTTON.*"
465+
# Excludes button.*, Button.*, BUTTON.*, etc.
466+
467+
# Case-sensitive exclusion
468+
lrm view "*" --not "Button.*" --case-sensitive
469+
# Only excludes exact case matches
470+
471+
# Export filtered results
472+
lrm view "*" --status partial --not "Test.*" --format json
473+
# Get partially translated keys, excluding tests
474+
```
475+
476+
**Exclusion Patterns:**
477+
- Supports exact matches: `Button.Save`
478+
- Supports wildcards: `Test.*`, `*.Debug`, `*temp*`
479+
- **Multiple patterns:** Use multiple `--not` flags (recommended) or comma-separated in quotes
480+
- Matches key names only (not values or comments)
481+
- Case-insensitive by default, use `--case-sensitive` to change
482+
483+
**Syntax Options:**
484+
```bash
485+
# Option 1: Multiple flags (recommended - shell-safe)
486+
lrm view "*" --not "Test.*" --not "Debug.*"
487+
488+
# Option 2: Comma-separated (must quote the entire value)
489+
lrm view "*" --not "Test.*,Debug.*"
490+
491+
# Option 3: Mix both (all patterns are combined)
492+
lrm view "*" --not "Test.*,Debug.*" --not "Temp.*"
493+
```
494+
339495
**Extra Keys Warning:**
340496

341497
The view command will warn you if filtered language files contain keys that don't exist in the default file:

0 commit comments

Comments
 (0)