Skip to content

Commit 77158f2

Browse files
committed
Update documentation for configuration file support and regex pattern matching
- Add configuration file support section in README and CI-CD docs - Document --config-file option and lrm.json auto-discovery - Add regex pattern matching examples for view command - Update commands table with format support for all commands - Add CI/CD use cases for regex-based key exploration - Add comprehensive regex examples in EXAMPLES.md
1 parent a4973e8 commit 77158f2

4 files changed

Lines changed: 390 additions & 16 deletions

File tree

CI-CD.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,29 @@ lrm export --format json -o translations.json
175175

176176
---
177177

178+
## Configuration File Support
179+
180+
LRM supports configuration files to avoid repeating common options. Create a `lrm.json` file in your resource directory:
181+
182+
```json
183+
{
184+
}
185+
```
186+
187+
LRM will automatically discover and use `lrm.json` in the resource path, or you can specify a custom config file:
188+
189+
```bash
190+
# Use auto-discovered lrm.json
191+
lrm validate --path ./Resources
192+
193+
# Use custom config file
194+
lrm validate --config-file ./my-config.json --path ./Resources
195+
```
196+
197+
In CI/CD workflows, you can commit your `lrm.json` to version control and all commands will use it automatically.
198+
199+
---
200+
178201
## Common Use Cases
179202

180203
### 1. Validate on Pull Requests
@@ -293,6 +316,48 @@ jobs:
293316
path: weekly-report.csv
294317
```
295318

319+
### 7. Explore Keys by Namespace with Regex Patterns
320+
321+
Use the `view` command with regex patterns to explore and document keys by namespace:
322+
323+
```yaml
324+
- name: Document Error Messages
325+
run: |
326+
# Export all error message keys to JSON for documentation
327+
lrm view "^Error\\..*" --regex --format json > error-messages.json
328+
329+
- name: Document UI Labels
330+
run: |
331+
# Export all label and button keys
332+
lrm view "^(Label|Button)\\." --regex --sort --format json > ui-elements.json
333+
334+
- name: Verify Validation Messages
335+
run: |
336+
# Check that all validation keys are present
337+
VALIDATION_KEYS=$(lrm view "Validation" --regex --format json | jq '.matchCount')
338+
if [ "$VALIDATION_KEYS" -lt 10 ]; then
339+
echo "Warning: Only $VALIDATION_KEYS validation keys found"
340+
exit 1
341+
fi
342+
```
343+
344+
### 8. Generate Translation Reports by Category
345+
346+
```yaml
347+
- name: Generate category-based translation reports
348+
run: |
349+
# Create reports for different key namespaces
350+
for category in Error Success Warning Label Button; do
351+
echo "Generating report for $category keys..."
352+
lrm view "^${category}\\." --regex --format simple --no-limit > "${category}-translations.txt"
353+
done
354+
355+
- uses: actions/upload-artifact@v4
356+
with:
357+
name: translation-reports
358+
path: "*-translations.txt"
359+
```
360+
296361
---
297362

298363
## Platform-Specific Notes

COMMANDS.md

Lines changed: 128 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,28 @@ Summary Table:
146146

147147
## view
148148

149-
**Description:** View details of a specific key across all languages.
149+
**Description:** View details of a specific key or multiple keys matching a regex pattern across all languages.
150150

151151
**Arguments:**
152-
- `<KEY>` - The key to view (required)
152+
- `<KEY>` - The key or regex pattern to view (required)
153153

154154
**Options:**
155155
- `-p, --path <PATH>` - Resource folder path
156+
- `-c, --config-file <PATH>` - Path to configuration file
157+
- `-f, --format <FORMAT>` - Output format: `table` (default), `json`, or `simple`
158+
- `--regex` - Treat KEY as a regular expression pattern
156159
- `--show-comments` - Include comments in output
157-
- `--format <FORMAT>` - Output format: `table` (default), `json`, or `simple`
160+
- `--limit <COUNT>` - Maximum number of keys to display (default: 100, 0 for no limit)
161+
- `--no-limit` - Show all matches without limit (same as --limit 0)
162+
- `--sort` - Sort matched keys alphabetically
163+
164+
**Modes:**
165+
- **Exact match (default):** View a single specific key
166+
- **Regex mode (with --regex):** View all keys matching a pattern
158167

159168
**Examples:**
169+
170+
**Single Key (Exact Match):**
160171
```bash
161172
# View key in table format (default)
162173
lrm view SaveButton
@@ -171,9 +182,36 @@ lrm view SaveButton --format json
171182
lrm view SaveButton --format simple
172183
```
173184

185+
**Multiple Keys (Regex Pattern):**
186+
```bash
187+
# View all Error keys
188+
lrm view "Error\..*" --regex
189+
190+
# View all button keys with comments
191+
lrm view "Button\..*" --regex --show-comments
192+
193+
# View numbered items (Item1, Item2, etc.)
194+
lrm view "Item[0-9]+" --regex
195+
196+
# View all keys containing "Validation"
197+
lrm view ".*Validation.*" --regex
198+
199+
# View with sorting
200+
lrm view "Success\..*" --regex --sort
201+
202+
# View all matches (no limit)
203+
lrm view ".*" --regex --no-limit
204+
205+
# Custom limit of 50 matches
206+
lrm view ".*Label.*" --regex --limit 50
207+
208+
# JSON output for automation
209+
lrm view "Error\..*" --regex --format json
210+
```
211+
174212
**Output formats:**
175213

176-
**Table (default):**
214+
**Table (single key):**
177215
```
178216
Key: SaveButton
179217
@@ -183,9 +221,32 @@ Key: SaveButton
183221
│ English │ Save │
184222
│ Greek │ Σώσει │
185223
└───────────┴────────┘
224+
225+
Present in 2/2 language(s), 0 empty value(s)
186226
```
187227

188-
**JSON:**
228+
**Table (multiple keys with regex):**
229+
```
230+
Pattern: Error\..*
231+
Matched 3 key(s)
232+
233+
┌───────────────────┬──────────────┬─────────────────┐
234+
│ Key │ Language │ Value │
235+
├───────────────────┼──────────────┼─────────────────┤
236+
│ Error.NotFound │ English │ Item not found │
237+
│ │ Greek │ Δεν βρέθηκε │
238+
├───────────────────┼──────────────┼─────────────────┤
239+
│ Error.Validation │ English │ Invalid │
240+
│ │ Greek │ Άκυρο │
241+
├───────────────────┼──────────────┼─────────────────┤
242+
│ Error.Unauthorized│ English │ Access denied │
243+
│ │ Greek │ Απαγορεύεται │
244+
└───────────────────┴──────────────┴─────────────────┘
245+
246+
Showing 3 key(s) across 2 language(s)
247+
```
248+
249+
**JSON (single key):**
189250
```json
190251
{
191252
"key": "SaveButton",
@@ -196,6 +257,68 @@ Key: SaveButton
196257
}
197258
```
198259

260+
**JSON (multiple keys with regex):**
261+
```json
262+
{
263+
"pattern": "Error\\..*",
264+
"matchCount": 3,
265+
"keys": [
266+
{
267+
"key": "Error.NotFound",
268+
"translations": {
269+
"default": "Item not found",
270+
"el": "Δεν βρέθηκε"
271+
}
272+
},
273+
{
274+
"key": "Error.Validation",
275+
"translations": {
276+
"default": "Invalid",
277+
"el": "Άκυρο"
278+
}
279+
},
280+
{
281+
"key": "Error.Unauthorized",
282+
"translations": {
283+
"default": "Access denied",
284+
"el": "Απαγορεύεται"
285+
}
286+
}
287+
]
288+
}
289+
```
290+
291+
**Simple (multiple keys):**
292+
```
293+
Pattern: Error\..*
294+
Matched 3 key(s)
295+
296+
--- Error.NotFound ---
297+
English (default): Item not found
298+
Greek: Δεν βρέθηκε
299+
300+
--- Error.Validation ---
301+
English (default): Invalid
302+
Greek: Άκυρο
303+
304+
--- Error.Unauthorized ---
305+
English (default): Access denied
306+
Greek: Απαγορεύεται
307+
```
308+
309+
**Safety Features:**
310+
- **Regex timeout:** 1-second limit prevents ReDoS attacks
311+
- **Default limit:** Shows first 100 matches to avoid overwhelming output
312+
- **Invalid pattern detection:** Clear error messages for malformed regex
313+
- **Backward compatible:** Exact match by default, regex is opt-in
314+
315+
**Use Cases:**
316+
- **Namespace exploration:** View all keys in a namespace (e.g., `Error.*`)
317+
- **Pattern discovery:** Find keys by pattern without knowing exact names
318+
- **Documentation:** Generate translation reports for specific areas
319+
- **Validation:** Check translations for entire feature groups
320+
- **CI/CD integration:** Export specific key groups as JSON
321+
199322
---
200323

201324
## add

0 commit comments

Comments
 (0)