mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-18 00:24:47 +04:00
Add --hook-args option to try-repo
This commit is contained in:
parent
99fa9ba5ef
commit
6d22fc01d0
3 changed files with 53 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import shlex
|
||||
import sys
|
||||
from collections.abc import Sequence
|
||||
|
||||
|
|
@ -171,6 +172,14 @@ def _add_run_options(parser: argparse.ArgumentParser) -> None:
|
|||
)
|
||||
|
||||
|
||||
def _add_hook_flags_option(parser: argparse.ArgumentParser) -> None:
|
||||
parser.add_argument(
|
||||
'--hook-args',
|
||||
type=shlex.split,
|
||||
help='Raw string with flags to pass into the hook (if specified).',
|
||||
)
|
||||
|
||||
|
||||
def _adjust_args_and_chdir(args: argparse.Namespace) -> None:
|
||||
# `--config` was specified relative to the non-root working directory
|
||||
if os.path.exists(args.config):
|
||||
|
|
@ -324,6 +333,7 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|||
),
|
||||
)
|
||||
_add_run_options(try_repo_parser)
|
||||
_add_hook_flags_option(try_repo_parser)
|
||||
|
||||
uninstall_parser = _add_cmd(
|
||||
'uninstall', help='Uninstall the pre-commit script.',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue