# scaffold/semantic_injection/directives/git_domain.py

"""
=================================================================================
== THE GUARDIAN OF HISTORY (V-Ω-GIT-DOMAIN)                                    ==
=================================================================================
LIF: 1,000,000,000

This artisan implements the `@git` namespace. It provides standard,
battle-tested exclusion patterns (`.gitignore` content) for various technologies.

Usage:
    .gitignore :: @git/python
    .gitignore :: @git/node
=================================================================================
"""
from textwrap import dedent
from typing import Dict, Any

from ..contract import BaseDirectiveDomain
from ..loader import domain


@domain("git")
class GitDomain(BaseDirectiveDomain):
    """
    The Keeper of the Ignore Lists.
    """

    @property
    def namespace(self) -> str:
        return "git"

    def help(self) -> str:
        return "Generates standard .gitignore configurations for various languages (python, node, go, rust)."

    # =========================================================================
    # == THE RITES OF EXCLUSION                                              ==
    # =========================================================================

    def _directive_python(self, context: Dict[str, Any], *args, **kwargs) -> str:
        """
        @git/python
        Summons the sacred ward against __pycache__ and virtual environments.
        """
        return dedent("""
            # --- Python Gnostic Ward ---
            __pycache__/
            *.py[cod]
            *$py.class

            # Distribution / Packaging
            .Python
            build/
            develop-eggs/
            dist/
            downloads/
            eggs/
            .eggs/
            lib/
            lib64/
            parts/
            sdist/
            var/
            wheels/
            *.egg-info/
            .installed.cfg
            *.egg

            # Virtual Environments
            venv/
            .venv/
            env/
            .env
            .env.local

            # Unit Test / Coverage
            htmlcov/
            .tox/
            .nox/
            .coverage
            .coverage.*
            .cache
            nosetests.xml
            coverage.xml
            *.cover
            .hypothesis/
            .pytest_cache/

            # Jupyter Notebook
            .ipynb_checkpoints

            # IDEs
            .vscode/
            .idea/
            *.swp
        """).strip()

    def _directive_node(self, context: Dict[str, Any], *args, **kwargs) -> str:
        """
        @git/node
        Summons the sacred ward against node_modules.
        """
        return dedent("""
            # --- Node.js Gnostic Ward ---
            node_modules/
            jspm_packages/

            # Logs
            logs
            *.log
            npm-debug.log*
            yarn-debug.log*
            yarn-error.log*

            # Runtime data
            pids
            *.pid
            *.seed
            *.pid.lock

            # Directory for instrumented libs generated by jscoverage/JSCover
            lib-cov

            # Coverage directory used by tools like istanbul
            coverage/

            # nyc test coverage
            .nyc_output

            # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
            .grunt

            # Bower dependency directory (https://bower.io/)
            bower_components

            # node-waf configuration
            .lock-wscript

            # Compiled binary addons (https://nodejs.org/api/addons.html)
            build/
            Release/

            # Dependency directories
            jspm_packages/

            # TypeScript v1 declaration files
            typings/

            # Optional npm cache directory
            .npm

            # Optional eslint cache
            .eslintcache

            # Environment Variables
            .env
            .env.test
            .env.production
        """).strip()

    def _directive_go(self, context: Dict[str, Any], *args, **kwargs) -> str:
        """
        @git/go
        Summons the sacred ward against binaries and vendor trash.
        """
        return dedent("""
            # --- Go Gnostic Ward ---
            # Binaries for programs and plugins
            *.exe
            *.exe~
            *.dll
            *.so
            *.dylib

            # Test binary, built with `go test -c`
            *.test

            # Output of the go coverage tool, specifically when used with LiteIDE
            *.out

            # Dependency directories (remove the comment below to include it)
            # vendor/

            # IDEs
            .vscode/
            .idea/
        """).strip()

    def _directive_rust(self, context: Dict[str, Any], *args, **kwargs) -> str:
        """
        @git/rust
        Summons the sacred ward for Cargo.
        """
        return dedent("""
            # --- Rust Gnostic Ward ---
            /target/
            **/*.rs.bk
            Cargo.lock

            # If you want to commit the lock file, remove the line above.
            # Generally recommended for applications, not for libraries.

            # IDEs
            .vscode/
            .idea/
        """).strip()

    def _directive_base(self, context: Dict[str, Any], *args, **kwargs) -> str:
        """
        @git/base
        The minimal ward for any project.
        """
        return dedent("""
            # --- Universal Gnostic Ward ---
            .DS_Store
            Thumbs.db
            .env
            .env.local
            .vscode/
            .idea/
            *.log
        """).strip()