Library for managing git hooks using pyproject.toml configuration with an extensible plugin system
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Complete command-line interface for managing autohooks installation, validation, and plugin management. The CLI provides all necessary commands for setting up and maintaining git hooks in Python projects.
Main command-line interface with subcommand routing and argument parsing, providing access to all autohooks functionality.
def main():
"""
Main CLI entry point with argument parsing and subcommand dispatch.
Handles version display, command completion, and routes to appropriate handlers.
"""Install and activate pre-commit hooks with different dependency management modes, with support for forced reinstallation and mode selection.
def install_hooks(term: Terminal, args: Namespace) -> None:
"""
Install autohooks pre-commit hook with specified mode.
Args:
term: Terminal interface for output
args: Parsed arguments containing force flag and mode setting
"""Usage Examples:
# Activate hooks with default mode
autohooks activate
# Force reinstall with specific mode
autohooks activate --force --mode poetry
# Activate with pipenv mode
autohooks activate --mode pipenvCheck the status of installed hooks, configuration validity, and plugin availability with comprehensive validation reporting.
def check_hooks(term: Terminal, args: Namespace) -> None:
"""
Validate installed hooks and configuration.
Args:
term: Terminal interface for output
args: Parsed arguments (currently unused)
"""
def check_pre_commit_hook(term: Terminal, pre_commit_hook: PreCommitHook) -> None:
"""
Check pre-commit hook installation status and version.
Args:
term: Terminal interface for output
pre_commit_hook: Hook instance to validate
"""
def check_config(term: Terminal, pyproject_toml: Path, pre_commit_hook: PreCommitHook) -> None:
"""
Validate pyproject.toml configuration and plugin availability.
Args:
term: Terminal interface for output
pyproject_toml: Path to configuration file
pre_commit_hook: Hook instance for mode comparison
"""Usage Examples:
# Check hook installation status
autohooks checkComprehensive plugin management system for adding, removing, and listing autohooks plugins with validation and status reporting.
def plugins(term: Terminal, args: Namespace) -> None:
"""
Plugin management dispatcher.
Args:
term: Terminal interface for output
args: Parsed arguments with plugins_func attribute
"""
def add_plugins(term: Terminal, args: Namespace) -> None:
"""
Add plugins to autohooks configuration.
Args:
term: Terminal interface for output
args: Parsed arguments with plugin names to add
"""
def remove_plugins(term: Terminal, args: Namespace) -> None:
"""
Remove plugins from autohooks configuration.
Args:
term: Terminal interface for output
args: Parsed arguments with plugin names to remove
"""
def list_plugins(term: Terminal, args: Namespace) -> None:
"""
List currently configured plugins with status validation.
Args:
term: Terminal interface for output
args: Parsed arguments (currently unused)
"""
def print_current_plugins(term: Terminal, current_plugins: Iterable[str]) -> None:
"""
Display current plugins with validation status.
Args:
term: Terminal interface for output
current_plugins: Iterator of plugin names to display
"""Usage Examples:
# Add single plugin
autohooks plugins add autohooks.plugins.black
# Add multiple plugins
autohooks plugins add autohooks.plugins.black autohooks.plugins.ruff
# Remove plugins
autohooks plugins remove autohooks.plugins.mypy
# List current plugins
autohooks plugins listautohooks activateInstall and activate pre-commit hooks.
Options:
-f, --force: Force activation even if hook exists-m, --mode {pythonpath,pipenv,poetry}: Dependency management modeautohooks checkValidate hook installation and configuration.
autohooks plugins add <plugin_names>Add plugins to configuration.
Arguments:
plugin_names: One or more plugin names to addautohooks plugins remove <plugin_names>Remove plugins from configuration.
Arguments:
plugin_names: One or more plugin names to removeautohooks plugins listList currently configured plugins with status.
from argparse import Namespace
from autohooks.terminal import TerminalInstall with Tessl CLI
npx tessl i tessl/pypi-autohooks