Commit 3c954cb
committed
refactor: centralize export path computation to shared library helper
IMPLEMENTATION (De-duplication Goal)
- Create compute_export_paths() helper in export.rs as single source of truth
- Helper returns (csv, headers, gpx, event) paths with consistent naming rules
- CLI now imports and uses compute_export_paths() instead of duplicating logic
- Removes local format_export_path() function from main.rs (was duplicating logic)
BENEFITS
- Single source of truth: filename/suffix logic lives only in export.rs
- Eliminates drift risk: if naming conventions change, update one place
- Better maintainability: path construction logic no longer duplicated
- Enables future enhancement: can extend naming rules without sync issues
TECHNICAL DETAILS
- compute_export_paths: centralizes base_name extraction, output_dir selection,
log_suffix calculation, and path assembly using Path::join() for OS compatibility
- Consistent fallback: uses "blackbox" as filename fallback (matches export.rs)
- Used by all three export paths: CSV, GPX, Event exports
- CLI status messages now derive paths from shared helper
VERIFICATION
✅ cargo fmt --all -- --check : PASS
✅ cargo clippy --all-targets : PASS (no warnings)
✅ cargo test --verbose : PASS (37 tests)
✅ cargo build --release : PASS
✅ CSV output vs master : PASS (87/87 files identical)
✅ Multi-log file handling : PASS (correct .NN suffixes)
IMPACT ON GOALS
- De-duplication: ✅ Removed duplicate path construction logic from CLI
- Shared library: ✅ compute_export_paths is now library API
- Unified behavior: ✅ Both export functions and CLI use same path logic1 parent be1a4ee commit 3c954cb
2 files changed
Lines changed: 71 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
28 | 75 | | |
29 | 76 | | |
30 | 77 | | |
| |||
312 | 359 | | |
313 | 360 | | |
314 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
315 | 381 | | |
316 | 382 | | |
317 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | 44 | | |
88 | 45 | | |
89 | 46 | | |
| |||
1116 | 1073 | | |
1117 | 1074 | | |
1118 | 1075 | | |
1119 | | - | |
| 1076 | + | |
1120 | 1077 | | |
1121 | 1078 | | |
1122 | 1079 | | |
| |||
1149 | 1106 | | |
1150 | 1107 | | |
1151 | 1108 | | |
1152 | | - | |
1153 | | - | |
| 1109 | + | |
| 1110 | + | |
1154 | 1111 | | |
1155 | 1112 | | |
1156 | 1113 | | |
| |||
1181 | 1138 | | |
1182 | 1139 | | |
1183 | 1140 | | |
1184 | | - | |
| 1141 | + | |
1185 | 1142 | | |
1186 | 1143 | | |
1187 | 1144 | | |
| |||
0 commit comments