import os import sys import shutil import glob def archive_feature(feature_name): archive_root = "archive" target_dir = os.path.join(archive_root, feature_name) print(f"Archiving feature '{feature_name}' to {target_dir}...") if not os.path.exists(target_dir): os.makedirs(target_dir) # Find all files related to this feature # Convention: {feature}.*.md or inside feature folders patterns = [ f"docs/**/*{feature_name}*.md", f"src/**/*{feature_name}*" ] moved_count = 0 for pattern in patterns: # Recursive glob files = glob.glob(pattern, recursive=True) for src in files: if os.path.isdir(src): continue # mirror logic logic is complex, for v1.0 let's just flatten or simple move # Simple move: archive/{feature}/{original_basename} basename = os.path.basename(src) dst = os.path.join(target_dir, basename) try: shutil.move(src, dst) print(f" Moved: {src} -> {dst}") moved_count += 1 except Exception as e: print(f" Error moving {src}: {e}") if moved_count > 0: print(f"✅ Successfully archived {moved_count} files.") else: print("⚠️ No files found to archive.") if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: python archive.py ") sys.exit(1) archive_feature(sys.argv[1])