|
15 | 15 | import typer |
16 | 16 | from typer import Context |
17 | 17 |
|
18 | | -logger = logging.getLogger(__name__) |
19 | | - |
20 | 18 | from code_assistant_manager.config import ConfigManager |
21 | 19 | from code_assistant_manager.mcp.cli import app as mcp_app |
22 | 20 | from code_assistant_manager.tools import ( |
|
25 | 23 | get_registered_tools, |
26 | 24 | ) |
27 | 25 |
|
| 26 | +logger = logging.getLogger(__name__) |
| 27 | + |
28 | 28 | app = typer.Typer( |
29 | 29 | name="cam", |
30 | 30 | help="Code Assistant Manager - CLI utilities for working with AI coding assistants", |
@@ -637,11 +637,87 @@ def doctor_alias( |
637 | 637 | return doctor(ctx, verbose) |
638 | 638 |
|
639 | 639 |
|
| 640 | +@app.command("validate") |
| 641 | +def validate_config( |
| 642 | + config: Optional[str] = typer.Option( |
| 643 | + None, "--config", "-c", help="Path to config file" |
| 644 | + ), |
| 645 | + verbose: bool = typer.Option(False, "--verbose", "-v", help="Show detailed output"), |
| 646 | +): |
| 647 | + """Validate the configuration file for syntax and semantic errors.""" |
| 648 | + from code_assistant_manager.config import ConfigManager |
| 649 | + from code_assistant_manager.menu.base import Colors |
| 650 | + |
| 651 | + try: |
| 652 | + cm = ConfigManager(config) |
| 653 | + typer.echo( |
| 654 | + f"{Colors.GREEN}✓ Configuration file loaded successfully{Colors.RESET}" |
| 655 | + ) |
| 656 | + |
| 657 | + # Run full validation |
| 658 | + is_valid, errors = cm.validate_config() |
| 659 | + |
| 660 | + if is_valid: |
| 661 | + typer.echo(f"{Colors.GREEN}✓ Configuration validation passed{Colors.RESET}") |
| 662 | + return 0 |
| 663 | + else: |
| 664 | + typer.echo(f"{Colors.RED}✗ Configuration validation failed:{Colors.RESET}") |
| 665 | + for error in errors: |
| 666 | + typer.echo(f" - {error}") |
| 667 | + return 1 |
| 668 | + |
| 669 | + except FileNotFoundError as e: |
| 670 | + typer.echo(f"{Colors.RED}✗ Configuration file not found: {e}{Colors.RESET}") |
| 671 | + return 1 |
| 672 | + except ValueError as e: |
| 673 | + typer.echo(f"{Colors.RED}✗ Configuration validation failed: {e}{Colors.RESET}") |
| 674 | + return 1 |
| 675 | + |
| 676 | + |
| 677 | +@app.command("validate") |
| 678 | +def validate_config( |
| 679 | + config: Optional[str] = typer.Option( |
| 680 | + None, "--config", "-c", help="Path to config file" |
| 681 | + ), |
| 682 | + verbose: bool = typer.Option(False, "--verbose", "-v", help="Show detailed output"), |
| 683 | +): |
| 684 | + """Validate the configuration file for syntax and semantic errors.""" |
| 685 | + from code_assistant_manager.config import ConfigManager |
| 686 | + from code_assistant_manager.menu.base import Colors |
| 687 | + |
| 688 | + try: |
| 689 | + cm = ConfigManager(config) |
| 690 | + typer.echo( |
| 691 | + f"{Colors.GREEN}✓ Configuration file loaded successfully{Colors.RESET}" |
| 692 | + ) |
| 693 | + |
| 694 | + # Run full validation |
| 695 | + is_valid, errors = cm.validate_config() |
| 696 | + |
| 697 | + if is_valid: |
| 698 | + typer.echo(f"{Colors.GREEN}✓ Configuration validation passed{Colors.RESET}") |
| 699 | + return 0 |
| 700 | + else: |
| 701 | + typer.echo(f"{Colors.RED}✗ Configuration validation failed:{Colors.RESET}") |
| 702 | + for error in errors: |
| 703 | + typer.echo(f" - {error}") |
| 704 | + return 1 |
| 705 | + |
| 706 | + except FileNotFoundError as e: |
| 707 | + typer.echo(f"{Colors.RED}✗ Configuration file not found: {e}{Colors.RESET}") |
| 708 | + return 1 |
| 709 | + except ValueError as e: |
| 710 | + typer.echo(f"{Colors.RED}✗ Configuration validation failed: {e}{Colors.RESET}") |
| 711 | + return 1 |
| 712 | + except Exception as e: |
| 713 | + typer.echo( |
| 714 | + f"{Colors.RED}✗ Unexpected error during validation: {e}{Colors.RESET}" |
| 715 | + ) |
| 716 | + return 1 |
| 717 | + |
| 718 | + |
640 | 719 | @app.command() |
641 | 720 | def completion(shell: str = typer.Argument(..., help="Shell type (bash, zsh)")): |
642 | | - """Generate shell completion script for bash or zsh (alias: comp)""" |
643 | | - |
644 | | - shell = shell.lower() |
645 | 721 | if shell not in ["bash", "zsh"]: |
646 | 722 | typer.echo(f"Error: Unsupported shell '{shell}'. Supported shells: bash, zsh") |
647 | 723 | raise typer.Exit(1) |
|
0 commit comments