"""
CLI framework core.

Provides the main CLI framework and command delegation.
"""

from typing import Any
from .commands import WorkspaceCommands, IssueCommands, ProjectCommands, ExportCommands, ConfigCommands


class CLIFramework:
    """Main CLI framework that delegates to command classes."""

    def __init__(self) -> None:
        self.workspace = WorkspaceCommands()
        self.issues = IssueCommands()
        self.project = ProjectCommands()
        self.export = ExportCommands()
        self.config = ConfigCommands()

    # Workspace operations
    def workspace_status(self) -> None:
        return self.workspace.status()

    def start_issue(self, issue_number: int) -> None:
        return self.workspace.start_issue(issue_number)

    def finish_issue(self) -> None:
        return self.workspace.finish_issue()

    def add_test_guidance(self) -> None:
        return self.workspace.add_test_guidance()

    # Issue operations
    def list_issues(self) -> None:
        return self.issues.list_issues()

    def list_open_issues(self) -> None:
        return self.issues.list_open_issues()

    def show_issue(self, issue_number: int) -> None:
        return self.issues.show_issue(issue_number)

    def create_issue(self, title: str, body: str, issue_type: str = "enhancement") -> None:
        return self.issues.create_issue(title, body, issue_type)

    def create_enhancement_issue(self, title: str, use_case: str, **kwargs: Any) -> None:
        return self.issues.create_enhancement_issue(title, use_case, **kwargs)

    def create_from_template(self, template_file: str, **kwargs: Any) -> None:
        return self.issues.create_from_template(template_file, **kwargs)

    def close_issue(self, issue_number: int, comment: str = "") -> None:
        return self.issues.close_issue(issue_number, comment)

    def analyze_coverage(self, issue_number: int) -> None:
        return self.issues.analyze_coverage(issue_number)

    # Project management operations
    def setup_project_management(self) -> None:
        return self.project.setup_project_management()

    def move_issue_to_state(self, issue_number: int, state: str) -> None:
        return self.project.move_issue_to_state(issue_number, state)

    def set_issue_priority(self, issue_number: int, priority: str) -> None:
        return self.project.set_issue_priority(issue_number, priority)

    def create_milestone(self, title: str, description: str = "") -> None:
        return self.project.create_milestone(title, description)

    def list_milestones(self) -> None:
        return self.project.list_milestones()

    def assign_issue_to_milestone(self, issue_number: int, milestone_id: int) -> None:
        return self.project.assign_issue_to_milestone(issue_number, milestone_id)

    def project_overview(self) -> None:
        return self.project.project_overview()

    # Export operations
    def issue_index(self, **kwargs: Any) -> None:
        return self.export.issue_index(**kwargs)

    def export_issues_csv(self, output_file: str = None) -> None:
        return self.export.export_issues_csv(output_file)

    def export_issues_json(self, output_file: str = None) -> None:
        return self.export.export_issues_json(output_file)

    def export_issue_index(self, output_file: str = None) -> None:
        return self.export.issue_index(format_type="tsv", output_file=output_file)

    # Configuration operations
    def show_config(self, show_sensitive: bool = False) -> None:
        return self.config.show_config(show_sensitive)

    def validate_config(self, verbose: bool = False) -> None:
        return self.config.validate_config(verbose)

    def troubleshoot_config(self) -> None:
        return self.config.troubleshoot_config()

    def check_config_files(self) -> None:
        return self.config.check_config_files()