def export_json(self, filepath, clean_names=False): with open(filepath, 'w', encoding='utf-8') as f: json.dump(self.get_list(clean_names), f, indent=2) CLI Interface ------------------------------ def main(): parser = argparse.ArgumentParser(description="RomLister - Scan and filter ROM collections") parser.add_argument("directory", help="Root directory to scan for ROMs") parser.add_argument("-r", "--recursive", action="store_true", help="Scan subfolders recursively") parser.add_argument("-e", "--extensions", nargs="+", help="File extensions to include (e.g., nes sfc iso)") parser.add_argument("--min-size", type=int, help="Minimum file size in bytes") parser.add_argument("--max-size", type=int, help="Maximum file size in bytes") parser.add_argument("-p", "--pattern", help="Regex pattern to filter by filename") parser.add_argument("-c", "--clean-names", action="store_true", help="Remove region/version tags") parser.add_argument("-o", "--output", help="Output file path") parser.add_argument("-f", "--format", choices=["txt", "csv", "json"], default="txt", help="Output format") parser.add_argument("--list-only", action="store_true", help="Print list to console")
def get_list(self, clean_names=False): """Return list of ROM file paths or cleaned names.""" if clean_names: return [self.clean_name(r.stem) for r in self.roms] return [str(r) for r in self.roms] romlister
def scan(self): """Scan directory and collect ROM files.""" if self.recursive: iterator = self.root_path.rglob("*") else: iterator = self.root_path.glob("*") clean_names=False): with open(filepath