You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* refactor: complete CLI-to-crate unification by consolidating export layer
- Move export functionality from CLI (src/main.rs) to library (src/export.rs)
- Remove 541 lines of duplicated export code from main.rs
- Reduce main.rs from ~1822 to ~1417 lines (22% reduction)
- CLI now uses library export functions: export_to_csv, export_to_gpx, export_to_event
- Enhance export_to_gpx with log_start_datetime parameter for accurate timestamps
- Remove unused structs: CsvExportOptions, CsvFieldMap from main.rs
- Update examples to use new export_to_gpx signature
- Update AGENTS.md to document full unification completion
Resolves issue #24: Complete CLI-to-Crate Unification
All tests pass (38 total):
- cargo clippy --all-targets --all-features -- -D warnings ✓
- cargo fmt --all -- --check ✓
- cargo test --verbose ✓ (38 passed)
- cargo test --features=cli --verbose ✓
- cargo build --release ✓ (no warnings)
* refactor: consolidate export status formatting and enhance tests
- Extract format_export_path() helper to eliminate duplication across CSV, GPX,
and Event export status messages (3 blocks -> 1 reusable function)
- Document GPX timestamp performance considerations for large GPS traces
- Enhance test_export_options() with comprehensive assertions for all fields:
- Validate event, force_export, and output_dir in both explicit and default configs
- Now covers all 5 ExportOptions fields (was 3 fields previously)
- CSV output: 87/87 files remain byte-for-byte identical to master (verified)
- Maintains CLI as thin wrapper over shared library export functions
- No functional changes to export logic or output data
* fix: use log.log_number directly in format_export_path for consistency
- Change format_export_path parameter from log_index to log_number (1-based)
- Use log.log_number directly instead of computed log_index + 1
- Aligns with export.rs behavior which uses log.log_number for file suffix
- Eliminates fragile dual calculation that could drift if assumptions change
- All call sites updated to pass log.log_number
- No change to output data (87/87 CSV files still match master)
* refactor: use PathBuf for cross-platform path assembly in status messages
- Change format_export_path to return (PathBuf, PathBuf, PathBuf, PathBuf) for all export types
- Compute full paths using Path::join() instead of manual string concatenation with '/'
- Use PathBuf::display() for OS-aware path printing (e.g., backslashes on Windows)
- Ensures printed paths match actual OS path separators, fixing mixed separator issue
- Fallback values ("blackbox") already consistent with export.rs
- All call sites updated to use dedicated path variables for clarity
- CSV output: 87/87 files remain byte-for-byte identical to master
* 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 logic
* refactor: remove unnecessary path computation from export_to_gpx early return
IMPROVES SEPARATION OF CONCERNS
- export_to_gpx() should only export data, not compute paths for messaging
- Removed unnecessary path computation when gps_coordinates is empty
- CLI already uses compute_export_paths() for message generation
- Export functions stay focused on their core responsibility
BENEFITS
- Cleaner library API: export functions don't couple to CLI messaging needs
- Better separation of concerns: path computation is CLI responsibility
- More reusable: export functions can be used by other tools without side effects
- Supports goal: Moving to shared libraries for both CLI and crate usage
IMPLEMENTATION
- Removed ~20 lines of path computation code from export_to_gpx early return
- CLI message generation unchanged (already uses compute_export_paths)
- export_to_event was already correct (had early return without path computation)
VERIFICATION
✅ cargo fmt --all -- --check : PASS
✅ cargo clippy --all-targets : PASS
✅ cargo test --verbose : PASS (37 tests)
✅ cargo build --release : PASS
✅ CSV output vs master : PASS (87/87 files identical)
✅ GPX/event messaging : PASS (messages still displayed correctly)
ALIGNMENT WITH GOALS
✅ De-duplication: Further reduced code duplication
✅ Shared libraries: Export functions now cleaner library APIs
✅ Better separation: Export functions don't depend on CLI messaging
* refactor: unify base filename fallback to "blackbox" across all exports
ADDRESSES INCONSISTENCY
- Issue: export_to_gpx and export_to_event used "unknown" fallback
compute_export_paths and export_to_csv used "blackbox"
This violated the contract: "ensures CLI status messages match actual filenames"
IMPLEMENTATION
- Created extract_base_name() helper for consistent filename derivation
- All export functions now use this shared helper
- Guarantees consistent "blackbox" fallback everywhere
- Eliminates duplication of base name extraction logic
BENEFITS FOR DEDUPLICATION GOAL
✅ Single source of truth: extract_base_name() is used by:
- compute_export_paths() for CLI message prediction
- export_to_csv() for actual CSV output
- export_to_gpx() for actual GPX output
- export_to_event() for actual event output
✅ Prevents drift: If base name logic changes, one place to update
✅ Reduces duplication: Shared helper eliminates 4 copies of same logic
✅ Supports library API: Export functions now truly match predictions
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)
IMPACT ON GOALS
✅ De-duplication: Removed duplicate base name extraction (4 copies -> 1)
✅ Shared libraries: All exports use same fallback, guaranteeing consistency
✅ Single source of truth: One place to define filename conventions
Copy file name to clipboardExpand all lines: AGENTS.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,15 +13,14 @@
13
13
14
14
## Architecture & Code Organization
15
15
-**Library-first design:** Core logic in `src/lib.rs` and CLI entry point in `src/main.rs`.
16
-
-**Shared code:** Parser modules (`src/parser/`) are used by both library and CLI (`parse_frames`, `parse_headers_from_text`).
17
-
-**Duplicated code:**Export implementations exist separately in `src/export.rs` (library) and `src/main.rs` (CLI). CLI does NOT use library export functions.
0 commit comments