By default, pre-commit only allows invoking a hook with its preconfigured arguments:
pre-commit run example-hookPassing different arguments to different invocations requires defining each permutation as a separate entry in .pre-commit-config.yaml with specific args: [...]. This doesn't support using hooks as general-purpose tools with dynamic arguments.
When --tool is used:
allow_all_files=trueis implied- The hook must be exposed with
stages: ["manual"] - Arbitrary arguments can be passed after
--
pre-commit run <hook-id> --tool -- [arguments...]pre-commit run example-hook --tool -- --arg1 --arg2=4This invokes example-hook with --arg1 and --arg2=4 passed directly to the underlying tool, without needing a predefined entry for each argument combination.
A framework for managing and maintaining multi-language pre-commit hooks.
For more information see: https://pre-commit.com/