108 Zeilen
3.6 KiB
Python
108 Zeilen
3.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Refactoring Management Tool
|
|
Manage feature flags for the MainWindow refactoring
|
|
"""
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
from gui.config import refactoring_config
|
|
|
|
def show_status():
|
|
"""Show current refactoring status"""
|
|
status = refactoring_config.get_status()
|
|
print("\n=== Refactoring Configuration Status ===")
|
|
print(f"Config file: {status['config_file']}")
|
|
print("\nFeature Flags:")
|
|
for flag, value in status['flags'].items():
|
|
status_str = "✅ ENABLED" if value else "❌ DISABLED"
|
|
print(f" {flag}: {status_str}")
|
|
print()
|
|
|
|
def enable_handler(handler_name):
|
|
"""Enable a specific handler"""
|
|
refactoring_config.enable_handler(handler_name)
|
|
refactoring_config.save_config()
|
|
print(f"✅ Enabled {handler_name} handler")
|
|
# Reload config to show updated status
|
|
from gui.config import RefactoringConfig
|
|
updated_config = RefactoringConfig()
|
|
status = updated_config.get_status()
|
|
print("\n=== Refactoring Configuration Status ===")
|
|
print(f"Config file: {status['config_file']}")
|
|
print("\nFeature Flags:")
|
|
for flag, value in status['flags'].items():
|
|
status_str = "✅ ENABLED" if value else "❌ DISABLED"
|
|
print(f" {flag}: {status_str}")
|
|
print()
|
|
|
|
def disable_all():
|
|
"""Disable all refactoring features"""
|
|
refactoring_config.disable_all()
|
|
refactoring_config.save_config()
|
|
print("❌ All refactoring features disabled")
|
|
show_status()
|
|
|
|
def set_flag(flag_name, value):
|
|
"""Set a specific flag"""
|
|
refactoring_config.set(flag_name, value)
|
|
refactoring_config.save_config()
|
|
status_str = "enabled" if value else "disabled"
|
|
print(f"✅ Flag {flag_name} {status_str}")
|
|
show_status()
|
|
|
|
def create_test_config():
|
|
"""Create a test configuration with gradual enablement"""
|
|
print("\n=== Creating Test Configuration ===")
|
|
|
|
# Phase 1: Enable UI helpers only (safest)
|
|
print("\nPhase 1: UI Helpers only")
|
|
refactoring_config.disable_all()
|
|
refactoring_config.set('USE_UI_HELPERS', True)
|
|
refactoring_config.save_config()
|
|
|
|
print("\nTest with: python main.py")
|
|
print("If stable, proceed to Phase 2")
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description='Manage MainWindow refactoring')
|
|
subparsers = parser.add_subparsers(dest='command', help='Commands')
|
|
|
|
# Status command
|
|
subparsers.add_parser('status', help='Show current configuration')
|
|
|
|
# Enable command
|
|
enable_parser = subparsers.add_parser('enable', help='Enable a handler')
|
|
enable_parser.add_argument('handler', choices=['gitea', 'process', 'project', 'ui'],
|
|
help='Handler to enable')
|
|
|
|
# Disable all command
|
|
subparsers.add_parser('disable-all', help='Disable all refactoring features')
|
|
|
|
# Set flag command
|
|
set_parser = subparsers.add_parser('set', help='Set a specific flag')
|
|
set_parser.add_argument('flag', help='Flag name')
|
|
set_parser.add_argument('value', choices=['true', 'false'], help='Flag value')
|
|
|
|
# Test config command
|
|
subparsers.add_parser('test-config', help='Create test configuration')
|
|
|
|
args = parser.parse_args()
|
|
|
|
if args.command == 'status' or not args.command:
|
|
show_status()
|
|
elif args.command == 'enable':
|
|
enable_handler(args.handler)
|
|
elif args.command == 'disable-all':
|
|
disable_all()
|
|
elif args.command == 'set':
|
|
value = args.value.lower() == 'true'
|
|
set_flag(args.flag, value)
|
|
elif args.command == 'test-config':
|
|
create_test_config()
|
|
else:
|
|
parser.print_help()
|
|
|
|
if __name__ == '__main__':
|
|
main() |