v0.1.45 - CLI Code Refactoring (2025-12-14)¶
What Changed?¶
This release refactors the CLI code to improve maintainability and reduce code duplication. A new _set_rtc_time() helper function consolidates the device RTC time synchronization logic that was previously duplicated in the read and measure commands. The refactoring reduces code lines and improves readability without changing user-facing functionality.
What's New¶
RTC Time Synchronization Helper Function¶
What it does:
Extracts the device RTC time synchronization logic into a dedicated _set_rtc_time() helper function. This function sets the device's real-time clock (RTC) to the current PC time with proper error handling.
How to use it:
Internally used by read and measure CLI commands. No user-facing changes.
Code example:
def _set_rtc_time(cmd: Command, verbose: bool) -> None:
"""Set device RTC time to current PC time"""
try:
unixtime = int(time.time())
cmd.rtc_time(unixtime)
if verbose:
console.print(f"[blue]Device time set to {unixtime}[/blue]")
except (CommandTimeout, ResponseTimeout, KazunokoError):
if verbose:
console.print("[yellow]⚠ Failed to set device time[/yellow]")
Installation¶
Quick Start¶
# Get the release
git checkout vX.Y.Z
# Setup
task env:setup
# Run CLI
uv run kazunoko --help
What's Different from the Last Version?¶
✅ Added¶
_set_rtc_time()helper function for RTC time synchronization
🔧 Changed¶
readcommand now uses_set_rtc_time()helper (8 lines → 1 line)measurecommand now uses_set_rtc_time()helper (8 lines → 1 line)- Consolidated duplicate RTC time setting logic
🐛 Fixed¶
- Code duplication in RTC time synchronization between
readandmeasurecommands
Is It Safe to Upgrade?¶
Backward Compatible: Yes
- No breaking changes. This is an internal refactoring.
- User-facing CLI behavior remains unchanged.
- All existing commands work exactly as before.
Tests Passed¶
- ✅ Builds without errors
- ✅ CLI commands
readandmeasureexecute correctly - ✅ RTC time synchronization works in both commands
- ✅ Type checker validation (mypy)
Release Details¶
- Date: 2025-12-14
- Version: v0.1.45
- Files Changed: 1
src/kazunoko/cli.py: Added_set_rtc_time()helper function and refactoredreadandmeasurecommands- Breaking Changes: None
- Code Reduction: ~16 lines of duplicated code consolidated
Next Steps¶
- Consider extracting other duplicated CLI patterns (
_print_connecting(),_build_measure_metadata()) - Further refactoring of CLI helper functions to improve code maintainability
- Continue code quality improvements in subsequent releases