Skip to content

A framework for managing and maintaining multi-language pre-commit hooks.

License

Notifications You must be signed in to change notification settings

rmawatson/pre-commit-ex

 
 

Repository files navigation

build status pre-commit.ci status

This fork adds --tool argument to allow invocation of hooks as tools from the command line.

[Original PR]

Using pre-commit hooks as terminal tools

By default, pre-commit only allows invoking a hook with its preconfigured arguments:

pre-commit run example-hook

Passing 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.

The --tool flag

When --tool is used:

  • allow_all_files=true is implied
  • The hook must be exposed with stages: ["manual"]
  • Arbitrary arguments can be passed after --

Usage

pre-commit run <hook-id> --tool -- [arguments...]

Example

pre-commit run example-hook --tool -- --arg1 --arg2=4

This invokes example-hook with --arg1 and --arg2=4 passed directly to the underlying tool, without needing a predefined entry for each argument combination.

pre-commit

A framework for managing and maintaining multi-language pre-commit hooks.

For more information see: https://pre-commit.com/

About

A framework for managing and maintaining multi-language pre-commit hooks.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.4%
  • R 2.0%
  • Shell 0.5%
  • Dockerfile 0.1%
  • Lua 0.0%
  • Ruby 0.0%