# tool/core/cmd/rename.py import struct from core.utils import console, console_err from core.protocol import COMMANDS, ERRORS class rename: def __init__(self, bus): self.bus = bus def get(self, source_path: str, dest_path: str): source_path_bytes = source_path.encode('utf-8') dest_path_bytes = dest_path.encode('utf-8') payload = struct.pack('B', len(source_path_bytes)) + source_path_bytes payload += struct.pack('B', len(dest_path_bytes)) + dest_path_bytes self.bus.send_request(COMMANDS['rename'], payload) data = self.bus.receive_ack() if not data or data.get('type') == 'error': return None return { 'success': data.get('type') == 'ack', 'source_path': source_path, 'dest_path': dest_path } def print(self, result): if not result or not result.get('success'): return console.print( f"Pfad [info]{result['source_path']}[/info] wurde erfolgreich in " f"[info]{result['dest_path']}[/info] umbenannt." )