mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-17 09:46:06 +00:00
- Convert all hardcoded versions to dynamic loading from VERSION file - Reduce version update locations from 50+ to just 3 files - Add proper fallback handling for version reading - Update all CLI commands to use dynamic __version__ - Streamline future version management process This change makes version bumping much simpler - only need to update: 1. VERSION file 2. package.json 3. pyproject.toml
79 lines
2.6 KiB
Python
79 lines
2.6 KiB
Python
"""
|
|
SuperClaude CLI Base Module
|
|
|
|
Base class for all CLI operations providing common functionality
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
# Read version from VERSION file
|
|
try:
|
|
__version__ = (Path(__file__).parent.parent.parent / "VERSION").read_text().strip()
|
|
except Exception:
|
|
__version__ = "4.0.7" # Fallback
|
|
|
|
|
|
def get_command_info():
|
|
"""Get information about available commands"""
|
|
return {
|
|
"install": {
|
|
"name": "install",
|
|
"description": "Install SuperClaude framework components",
|
|
"module": "setup.cli.commands.install"
|
|
},
|
|
"update": {
|
|
"name": "update",
|
|
"description": "Update existing SuperClaude installation",
|
|
"module": "setup.cli.commands.update"
|
|
},
|
|
"uninstall": {
|
|
"name": "uninstall",
|
|
"description": "Remove SuperClaude framework installation",
|
|
"module": "setup.cli.commands.uninstall"
|
|
},
|
|
"backup": {
|
|
"name": "backup",
|
|
"description": "Backup and restore SuperClaude installations",
|
|
"module": "setup.cli.commands.backup"
|
|
}
|
|
}
|
|
|
|
|
|
class OperationBase:
|
|
"""Base class for all operations providing common functionality"""
|
|
|
|
def __init__(self, operation_name: str):
|
|
self.operation_name = operation_name
|
|
self.logger = None
|
|
|
|
def setup_operation_logging(self, args):
|
|
"""Setup operation-specific logging"""
|
|
from ..utils.logger import get_logger
|
|
self.logger = get_logger()
|
|
self.logger.info(f"Starting {self.operation_name} operation")
|
|
|
|
def validate_global_args(self, args):
|
|
"""Validate global arguments common to all operations"""
|
|
errors = []
|
|
|
|
# Validate install directory
|
|
if hasattr(args, 'install_dir') and args.install_dir:
|
|
from ..utils.security import SecurityValidator
|
|
is_safe, validation_errors = SecurityValidator.validate_installation_target(args.install_dir)
|
|
if not is_safe:
|
|
errors.extend(validation_errors)
|
|
|
|
# Check for conflicting flags
|
|
if hasattr(args, 'verbose') and hasattr(args, 'quiet'):
|
|
if args.verbose and args.quiet:
|
|
errors.append("Cannot specify both --verbose and --quiet")
|
|
|
|
return len(errors) == 0, errors
|
|
|
|
def handle_operation_error(self, operation: str, error: Exception):
|
|
"""Standard error handling for operations"""
|
|
if self.logger:
|
|
self.logger.exception(f"Error in {operation} operation: {error}")
|
|
else:
|
|
print(f"Error in {operation} operation: {error}")
|
|
return 1 |