Compare commits
8 Commits
527ba0ab72
...
5993fc38e7
| Author | SHA1 | Date |
|---|---|---|
|
|
5993fc38e7 | |
|
|
e4006dea72 | |
|
|
e461417f4e | |
|
|
97654f2813 | |
|
|
87378081ee | |
|
|
bb21390881 | |
|
|
be63667ca5 | |
|
|
986177c01f |
18
src/_cmake
18
src/_cmake
|
|
@ -51,8 +51,6 @@
|
|||
#
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
local context state line curcontext="$curcontext" cmake_args
|
||||
|
||||
local -a cmake_build_options=(
|
||||
'-S[Explicitly specify a source directory]:source directory:_path_files -/'
|
||||
'-B[Explicitly specify a build directory]:build directory:_path_files -/'
|
||||
|
|
@ -235,7 +233,7 @@ _cmake_on_build() {
|
|||
|
||||
if [[ "$in_build" == false || "$difference" -eq 1 ]] ; then
|
||||
# either there is no --build or completing the directory after --build
|
||||
_arguments -C -s \
|
||||
_arguments -s \
|
||||
- build_opts \
|
||||
"$cmake_build_options[@]" \
|
||||
- build_cmds \
|
||||
|
|
@ -303,7 +301,7 @@ _cmake_on_install() {
|
|||
|
||||
if [[ "$in_build" == false || "$difference" -eq 1 ]] ; then
|
||||
# either there is no --install or completing the directory after --install
|
||||
_arguments -C -s \
|
||||
_arguments -s \
|
||||
- build_opts \
|
||||
"$cmake_build_options[@]" \
|
||||
- build_cmds \
|
||||
|
|
@ -600,18 +598,18 @@ _cmake_commands() {
|
|||
_describe -t commands 'command' commands
|
||||
}
|
||||
|
||||
local cmake_suggest_build;cmake_suggest_build=(
|
||||
'--build[build]:build dir:_cmake_suggest_builddirs'
|
||||
local -a cmake_suggest_build=(
|
||||
'--build[build]:build dir:_cmake_suggest_builddirs'
|
||||
)
|
||||
|
||||
local cmake_suggest_install;cmake_suggest_install=(
|
||||
'--install[install]:install dir:_cmake_suggest_installdirs'
|
||||
local -a cmake_suggest_install=(
|
||||
'--install[install]:install dir:_cmake_suggest_installdirs'
|
||||
)
|
||||
|
||||
if [[ "$service" = -value-*CMAKE_GENERATOR* ]]; then
|
||||
_cmake_generators
|
||||
elif [ $CURRENT -eq 2 ] ; then
|
||||
_arguments -C -s \
|
||||
_arguments -s \
|
||||
- help \
|
||||
"$cmake_help_actions[@]" \
|
||||
- command \
|
||||
|
|
@ -626,6 +624,8 @@ elif [[ $words[2] == --build ]] ; then
|
|||
_cmake_on_build
|
||||
elif [[ $words[2] == --install ]] ; then
|
||||
_cmake_on_install
|
||||
elif [[ $words[2] == --help-* ]] ; then
|
||||
_arguments "$cmake_help_actions[@]"
|
||||
else
|
||||
_arguments "$cmake_build_options[@]"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -0,0 +1,156 @@
|
|||
#compdef cpack
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2026 Github zsh-users - https://github.com/zsh-users
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for cpack 4.3.0 (https://kitware.com/cmake)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_cpack() {
|
||||
local ret=1
|
||||
|
||||
_arguments \
|
||||
'-G[Override/define CPACK_GENERATOR]:generator:_cpack_generators' \
|
||||
'-C[Specify the project configurations]:configuration:(Debug Release)' \
|
||||
*'-D[Set a CPack variable]:var_val' \
|
||||
'--config[Specify the config file]:file:_files' \
|
||||
'(-V --verbose)'{-V,--verbose}'[Enable verbose output]' \
|
||||
'--trace[Put underlying cmake scripts in trace mode]' \
|
||||
'--trace-expand[Put underlying cmake scripts in expanded trace mode]' \
|
||||
'--debug[Enable debug output]' \
|
||||
'-P[Override/define CPACK_PACKAGE_NAME]:package_name' \
|
||||
'-R[Override/define CPACK_PACKAGE_VERSION]:package_version' \
|
||||
'-B[Override/define CPACK_PACKAGE_DIRECTORY]:package_directory:_files -/' \
|
||||
'--vendor[Override/define CPACK_PACKAGE_VENDOR]:vendor' \
|
||||
'--preset[Read arguments from a package preset]' \
|
||||
'--list-presets[List available package preset]' \
|
||||
'(- *)'{--version,-version}=-'[Print version number and exit]::format:(json-v1)' \
|
||||
'(- *)--help[Print usage information and exit]' \
|
||||
'(- *)--help-full[Print all help manuals and exit]' \
|
||||
'(- *)--help-manual[Print one help manual and exit]:manual:_cpack_help_manuals' \
|
||||
'(- *)--help-manual-list[List help manuals available and exit]' \
|
||||
'(- *)--help-command[Print help for one command and exit]:command:_cpack_help_commands' \
|
||||
'(- *)--help-command-list[List commands with help available and exit]' \
|
||||
'(- *)--help-commands[Print cmake-commands manual and exit]' \
|
||||
'(- *)--help-module[Print help for one module and exit]:module:_cpack_help_modules' \
|
||||
'(- *)--help-module-list[List modules with help available and exit]' \
|
||||
'(- *)--help-modules[Print cmake-modules manual and exit]' \
|
||||
'(- *)--help-policy[Print help for one policy and exit]:policy:_cpack_help_policies' \
|
||||
'(- *)--help-policy-list[List policies with help available and exit]' \
|
||||
'(- *)--help-policies[Print cmake-policies manual and exit]' \
|
||||
'(- *)--help-property[Print help for one property and exit]:property:_cpack_help_properties' \
|
||||
'(- *)--help-property-list[List properties with help available and exit]' \
|
||||
'(- *)--help-properties[Print cmake-properties manual and exit]' \
|
||||
'(- *)--help-variable[Print help for one variable and exit]:variable:_cpack_help_variables' \
|
||||
'(- *)--help-variable-list[List variables with help available and exit]' \
|
||||
'(- *)--help-variables[Print cmake-variables manual and exit]' \
|
||||
&& ret=0
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_cpack_generators() {
|
||||
local -a generators=(
|
||||
"7Z:[7-Zip file format with default compression algorithm]"
|
||||
"7Z_BZ2:[7-Zip file format with BZip2 compression]"
|
||||
"7Z_DEFLATE:[7-Zip file format with Deflate compression]"
|
||||
"7Z_LZMA:[7-Zip file format with LZMA compression]"
|
||||
"7Z_LZMA2:[7-Zip file format with LZMA2 compression]"
|
||||
"7Z_PPMD:[7-Zip file format with PPMd compression]"
|
||||
"7Z_STORE:[7-Zip file format without compression]"
|
||||
"7Z_ZSTD:[7-Zip file format with Zstandard compression]"
|
||||
"AppImage:[AppImage packages]"
|
||||
"DEB:[Debian packages]"
|
||||
"External:[CPack External packages]"
|
||||
"IFW:[Qt Installer Framework]"
|
||||
"INNOSETUP:[Inno Setup packages]"
|
||||
"NSIS:[Null Soft Installer]"
|
||||
"NSIS64:[Null Soft Installer (64-bit)]"
|
||||
"NuGet:[NuGet packages]"
|
||||
"RPM:[RPM packages]"
|
||||
"STGZ:[Self extracting Tar GZip compression]"
|
||||
"TAR:[Tar no compression]"
|
||||
"TBZ2:[Tar BZip2 compression]"
|
||||
"TGZ:[Tar GZip compression]"
|
||||
"TXZ:[Tar XZ compression]"
|
||||
"TZ:[Tar Compress compression]"
|
||||
"TZST:[Tar Zstandard compression]"
|
||||
"ZIP:[ZIP file format with default compression algorithm]"
|
||||
"ZIP_BZ2:[ZIP file format with BZip2 compression]"
|
||||
"ZIP_DEFLATE:[ZIP file format with Deflate compression]"
|
||||
"ZIP_LZMA:[ZIP file format with LZMA compression]"
|
||||
"ZIP_LZMA2:[ZIP file format with LZMA2 compression]"
|
||||
"ZIP_STORE:[ZIP file format without compression]"
|
||||
"ZIP_ZSTD:[ZIP file format with Zstandard compression]"
|
||||
)
|
||||
|
||||
_describe -t 'generators' generator generators
|
||||
}
|
||||
|
||||
_cpack_help_manuals() {
|
||||
local -a manuals=(${(f)"$(cpack --help-manual-list 2>/dev/null | sed 's/([0-9]\+)$//' )"})
|
||||
_values 'manual' $manuals
|
||||
}
|
||||
|
||||
_cpack_help_commands() {
|
||||
local -a commands=(${(f)"$(cpack --help-command-list 2>/dev/null )"})
|
||||
_values 'command' $commands
|
||||
}
|
||||
|
||||
_cpack_help_modules() {
|
||||
local -a modules=(${(f)"$(cpack --help-module-list 2>/dev/null )"})
|
||||
_values 'module' $modules
|
||||
}
|
||||
|
||||
_cpack_help_policies() {
|
||||
local -a policies=(${(f)"$(cpack --help-policy-list 2>/dev/null )"})
|
||||
_values 'policy' $policies
|
||||
}
|
||||
|
||||
_cpack_help_properties() {
|
||||
local -a properties=(${(f)"$(cpack --help-property-list 2>/dev/null )"})
|
||||
_values 'property' $properties
|
||||
}
|
||||
|
||||
_cpack_help_variables() {
|
||||
local -a variables=(${(f)"$(cpack --help-variable-list 2>/dev/null )"})
|
||||
_values 'variable' $variables
|
||||
}
|
||||
|
||||
_cpack "$@"
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
#compdef ctest
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2026 Github zsh-users - https://github.com/zsh-users
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for ctest 4.3.0 (https://kitware.com/cmake)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_ctest() {
|
||||
local ret=1
|
||||
|
||||
_arguments \
|
||||
'--preset=[Read arguments from a test preset]:preset' \
|
||||
'--list-presets[List available test presets]' \
|
||||
'(-C --build-config)'{-C,--build-config}'[Choose configuration to test]:config' \
|
||||
'--progress[Enable short progress output from tests]' \
|
||||
'(-V --verbose -VV --extra-verbose)'{-V,--verbose}'[Enable verbose output from tests]' \
|
||||
'(-V --verbose -VV --extra-verbose)'{-VV,--extra-verbose}'[Enable more verbose output from tests]' \
|
||||
'--debug[Displaying more verbose internals of CTest]' \
|
||||
'--output-on-failure[Output anything outputted by the test program if the test should fail]' \
|
||||
'--stop-on-failure[Stop running the tests after one has failed]' \
|
||||
'--test-output-size-passed[Limit the output for passed tests to <size> bytes]:size' \
|
||||
'--test-output-size-failed[Limit the output for failed tests to <size> bytes]:size' \
|
||||
'--test-output-truncation[Truncate mode]:mode:(tail middle head)' \
|
||||
'-F[Enable failover]' \
|
||||
'(-j --parallel)'{-j,--parallel}'[Run tests in parallel]::level' \
|
||||
'(-Q --quiet)'{-Q,--quiet}'[Make ctest quiet]' \
|
||||
'(-O --output-log)'{-O,--output-log}'[Output to log file]:file:_files' \
|
||||
'--output-junit[Output test results to JUnit XML file]:file:_files' \
|
||||
'(-N --show-only)'{-N,--show-only}'[Disable actual execution of tests]::format:(format human json-v1)' \
|
||||
\*{-L,--label-regex}'[Run tests with labels matching regular expression]:regex' \
|
||||
\*{-R,--tests-regex}'[Run tests matching regular expression]:regex' \
|
||||
\*{-E,--exclude-regex}'[Exclude tests matching regular expression]:regex' \
|
||||
\*{-LE,--label-exclude}'[Exclude tests with labels matching regular expression]:regex' \
|
||||
\*{-FA,--fixture-exclude-any}'[Do not automatically add any tests for fixtures matching regular expression]:regex' \
|
||||
\*{-FS,--fixture-exclude-setup}'[Do not automatically add setup tests for fixtures matching regular expression]:regex' \
|
||||
\*{-FC,--fixture-exclude-cleanup}'[Do not automatically add cleanup tests for fixtures matching regular expression]:regex' \
|
||||
'(--dashboard)'{-D,--dashboard}'[Execute dashboard test]:dashboard' \
|
||||
*'-D[Define a variable for script mode]:var' \
|
||||
'(-M --test-model)'{-M,--test-model}'[Set the model for a dashboard]:model' \
|
||||
'(-T --test-action)'{-T,--test-action}'[Set the dashboard action to perform]' \
|
||||
'--group[Specify what build group on the dashboard]:group' \
|
||||
\*{-S,--script,-Sp,--script-new-process}'[Execute a dashboard for a configuration]:script:_files' \
|
||||
'(-A --add-notes)'{-A,--add-notes}'[Add a notes file with submission]:file:_files' \
|
||||
'(-I --test-information)'{-I,--test-information}'[Run a specific number of tests by number]:number' \
|
||||
'(-U --union)'{-U,--union}'[Take the Union of -I and -R]' \
|
||||
'--rerun-failed[Run only the tests that failed previously]' \
|
||||
'--tests-from-file[Run the tests listed in the given file]:file:_files' \
|
||||
'--exclude-from-file[Run tests except those listed in the given file]:file:_files' \
|
||||
'--repeat-until-fail[Repeat each test to run <n> times without failing]:n' \
|
||||
'--repeat[Repeat each test to run <n> times]:condition-n:(until-fail: until-pass: after-timeout:)' \
|
||||
'--max-width[Set the max width for a test name to output]' \
|
||||
'--interactive-debug-mode[Set the interactive mode to 0 or 1]:n:(0 1)' \
|
||||
'--resource-spec-file[Set the resource spec file to use]:file:_files' \
|
||||
'--no-label-summary[Disable timing summary information for labels]' \
|
||||
'--no-subproject-summary[Disable timing summary information for subprojects]' \
|
||||
'--test-dir[Specify the directory in which to look for tests]:dir:_files -/' \
|
||||
'--build-and-test[Configure, build and run a test]' \
|
||||
*'--build-target[Specify a specific target to build]:target' \
|
||||
'--build-nocmake[Run the build without running cmake first]' \
|
||||
'--build-run-dir[Specify directory to run programs from]:dir:_files -/' \
|
||||
'--build-two-config[Run CMake twice]' \
|
||||
'--build-exe-dir[Specify the directory for the executable]:dir:_files -/' \
|
||||
'--build-generator[Specify the generator to use]:generator' \
|
||||
'--build-generator-platform[Specify the generator-specific platform]:generator_platform' \
|
||||
'--build-generator-toolset[Specify the generator-specific toolset]:build_toolset' \
|
||||
'--build-project[Specify the name of the project to build]:project' \
|
||||
'--build-makeprogram[Specify the make program to use]:make:_files' \
|
||||
'--build-noclean[Skip the make clean step]' \
|
||||
'--build-config-sample[A sample executable to use to determine the configuration]:sample' \
|
||||
*'--build-options[Add extra options to the build step]' \
|
||||
'--test-command[The test to run with the --build-and-test-option]:command' \
|
||||
'--test-timeout[The time limit in seconds]:timeout' \
|
||||
'--test-load[CPU load threshold for starting new parallel tests]:threshold' \
|
||||
'--tomorrow-tag[starts with next day tag]' \
|
||||
'--overwrite[Overwrite CTest configuration option]' \
|
||||
'--extra-submit[Submit extra files to the dashboard]:file:_files' \
|
||||
*'--http-header[Append HTTP header when submitting]:header' \
|
||||
'--schedule-random[Use a random order for scheduling tests]' \
|
||||
'--schedule-random-seed[Override seed for random order of tests]:seed' \
|
||||
'--submit-index[Submit individual dashboard tests with specific index]:index' \
|
||||
'--timeout[Set the default test timeout]:timeout' \
|
||||
'--stop-time[Set a time at which all tests should stop running]:time' \
|
||||
'--http1.0[Submit using HTTP 1.0]' \
|
||||
'--no-compress-output[Do not compress test output when submitting]' \
|
||||
'--print-labels[Print all available test labels]' \
|
||||
'--no-tests=[Regard no tests]:type:(error ignore)' \
|
||||
'(- *)'{--help,-help,-usage,-h,-H}'[Print usage information and exit]' \
|
||||
'(- *)'{--version,-version}'[Print version number and exit]' \
|
||||
'(- *)--help-full[Print all help manuals and exit]' \
|
||||
'(- *)--help-manual[Print one help manual and exit]:manual:_ctest_help_manuals' \
|
||||
'(- *)--help-manual-list[List help manuals available and exit]' \
|
||||
'(- *)--help-command[Print help for one command and exit]:command:_ctest_help_commands' \
|
||||
'(- *)--help-command-list[List commands with help available and exit]' \
|
||||
'(- *)--help-commands[Print cmake-commands manual and exit]' \
|
||||
'(- *)--help-module[Print help for one module and exit]:module:_ctest_help_modules' \
|
||||
'(- *)--help-module-list[List modules with help available and exit]' \
|
||||
'(- *)--help-modules[Print cmake-modules manual and exit]' \
|
||||
'(- *)--help-policy[Print help for one policy and exit]:policy:_ctest_help_policies' \
|
||||
'(- *)--help-policy-list[List policies with help available and exit]' \
|
||||
'(- *)--help-policies[Print cmake-policies manual and exit]' \
|
||||
'(- *)--help-property[Print help for one property and exit]:property:_ctest_help_properties' \
|
||||
'(- *)--help-property-list[List properties with help available and exit]' \
|
||||
'(- *)--help-properties[Print cmake-properties manual and exit]' \
|
||||
'(- *)--help-variable[Print help for one variable and exit]:variable:_ctest_help_variables' \
|
||||
'(- *)--help-variable-list[List variables with help available and exit]' \
|
||||
'(- *)--help-variables[Print cmake-variables manual and exit]' \
|
||||
&& ret=0
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_ctest_help_manuals() {
|
||||
local -a manuals=(${(f)"$(ctest --help-manual-list 2>/dev/null | sed 's/([0-9]\+)$//' )"})
|
||||
_values 'manual' $manuals
|
||||
}
|
||||
|
||||
_ctest_help_commands() {
|
||||
local -a commands=(${(f)"$(ctest --help-command-list 2>/dev/null )"})
|
||||
_values 'command' $commands
|
||||
}
|
||||
|
||||
_ctest_help_modules() {
|
||||
local -a modules=(${(f)"$(ctest --help-module-list 2>/dev/null )"})
|
||||
_values 'module' $modules
|
||||
}
|
||||
|
||||
_ctest_help_policies() {
|
||||
local -a policies=(${(f)"$(ctest --help-policy-list 2>/dev/null )"})
|
||||
_values 'policy' $policies
|
||||
}
|
||||
|
||||
_ctest_help_properties() {
|
||||
local -a properties=(${(f)"$(ctest --help-property-list 2>/dev/null )"})
|
||||
_values 'property' $properties
|
||||
}
|
||||
|
||||
_ctest_help_variables() {
|
||||
local -a variables=(${(f)"$(ctest --help-variable-list 2>/dev/null )"})
|
||||
_values 'variable' $variables
|
||||
}
|
||||
|
||||
_ctest "$@"
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
299
src/_pre-commit
299
src/_pre-commit
|
|
@ -14,12 +14,103 @@
|
|||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_pre_commit() {
|
||||
typeset -A opt_args
|
||||
local context state line curcontext="$curcontext"
|
||||
local ret=1
|
||||
|
||||
_arguments -C \
|
||||
'(- *)'{-h,--help}'[show help message and exit]' \
|
||||
'(- *)'{-V,--version}'[show version number and exit]' \
|
||||
'1:command:_pre_commit_commands' \
|
||||
'*:: :->args' \
|
||||
&& ret=0
|
||||
|
||||
case "$state" in
|
||||
(args)
|
||||
local -a options=(
|
||||
'(- : *)'{-h,--help}'[show this help message and exit]'
|
||||
"--color[Whether to use color in output(default: auto)]:color:(auto always never)"
|
||||
)
|
||||
local -a hook_types=(
|
||||
commit-msg post-checkout post-commit post-merge post-rewrite pre-commit
|
||||
pre-merge-commit pre-push pre-rebase prepare-commit-msg
|
||||
)
|
||||
local -a hook_stages=($hook_types[@] manual)
|
||||
|
||||
case $words[1] in
|
||||
(help)
|
||||
_pre_commit_commands && ret=0
|
||||
return ret
|
||||
(autoupdate|init-templatedir|install|install-hooks|migrate-config|run|uninstall)
|
||||
options+=(
|
||||
'(-c --config)'{-c,--config}'[Path to alternate config file]:config:_files -g "*.yaml"'
|
||||
)
|
||||
;|
|
||||
(init-templatedir|install|uninstall)
|
||||
options+=(
|
||||
'(-t --hook-type)'{-t,--hook-type}'[hook type]:type:($hook_types)'
|
||||
)
|
||||
;|
|
||||
(autoupdate)
|
||||
options+=(
|
||||
'--bleeding-edge[Update to the bleeding edge of 'HEAD' instead of the latest tagged version]'
|
||||
'--freeze[Store "frozen" hashes in "rev" instead of tag names]'
|
||||
'*--repo[Only update this repository -- may be specified multiple times]:repos'
|
||||
'(-j --jobs)'{-j,--jobs}'[Number of threads to use(default: 1)]:jobs'
|
||||
)
|
||||
;;
|
||||
(init-templatedir)
|
||||
options+=(
|
||||
'--no-allow-missing-config[Assume cloned repos should have a "pre-commit" config]'
|
||||
'*::dir:_files -/'
|
||||
)
|
||||
;;
|
||||
(install)
|
||||
options+=(
|
||||
'(-f --overwrite)'{-f,--overwrite}'[Overwrite existing hooks / remove migration mode]'
|
||||
'--install-hooks[Whether to install hook environments for all environments]'
|
||||
'--allow-missing-config[Allow a missing "pre-commit" configuration file]'
|
||||
)
|
||||
;;
|
||||
(run|try-repo)
|
||||
options+=(
|
||||
'(-v --verbose)'{-v,--verbose}'[verbose mode]'
|
||||
'(-a --all-files)'{-a,--all-files}'[Run on all the files in the repo]'
|
||||
'--files[Specific filenames to run hooks on]:file:_files'
|
||||
'--show-diff-on-failure[When hooks fail, run "git diff" directly afterward]'
|
||||
'--hook-stage[The stage during which the hook is fired]:stage:($hook_stages)'
|
||||
'--remote-branch[Remote branch ref used by "git push"]:remote_branch:_pre_commit_git_remote_branches'
|
||||
'--local-branch[Local branch ref used by "git push"]:local_branch:_pre_commit_git_local_branches'
|
||||
'(--from-ref --source -s)'{--from-ref,--source,-s}'[original ref in "from_ref..to_ref" diff expression]:ref:_pre_commit_git_refs'
|
||||
'(--to-ref --origin -o)'{--to-ref,--origin,-o}'[destination ref in "from_ref..to_ref" diff expression]:ref:_pre_commit_git_refs'
|
||||
'--pre-rebase-upstream[upstream from which the series was forked]:upstream'
|
||||
'--pre-rebase-branch[branch being rebased and is not set when rebasing the current branch]:branch'
|
||||
'--commit-msg-filename[file name to check when running during "commit-msg"]:file:_files'
|
||||
'--prepare-commit-message-source[source of the commit message]:source'
|
||||
'--commit-object-name[commit object name]:object_name'
|
||||
'--remote-name[Remote name used by "git push"]:name:remote:_pre_commit_git_remotes'
|
||||
'--remote-url[Remote url used by "git push"]:url:_urls'
|
||||
'--checkout-type[branch check out or a file checkout]:type:_pre_commit_commit_types'
|
||||
'--is-squash-merge[use squash merge]:flag:(0 1)'
|
||||
'--rewrite-command[specify the command that invoked the rewrite]:command'
|
||||
"2:hook_id"
|
||||
)
|
||||
;;
|
||||
esac
|
||||
|
||||
_arguments $options[@] && ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_pre_commit_commands() {
|
||||
local commands=(
|
||||
local -a commands=(
|
||||
"autoupdate:Auto-update pre-commit config to the latest repos' versions"
|
||||
"clean:Clean out pre-commit files"
|
||||
"gc:Clean unused cached repos"
|
||||
"help:Show help for a specific command"
|
||||
"init-templatedir:Install hook script in a directory intended for use with 'git config init.templateDir'"
|
||||
"install:Install the pre-commit script"
|
||||
"install-hooks:Install hook environments for all environments in the config file"
|
||||
|
|
@ -32,181 +123,47 @@ _pre_commit_commands() {
|
|||
"validate-manifest:Validate .pre-commit-hooks.yaml files"
|
||||
"help:Show help for a specific command"
|
||||
)
|
||||
|
||||
_describe 'pre-commit commands' commands
|
||||
}
|
||||
|
||||
_pre_commit_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"(- : *)"{-V,--version}"[show program\'s version number and exit]"
|
||||
)
|
||||
|
||||
_pre_commit_autoupdate_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
|
||||
"--bleeding-edge[Update to the bleeding edge of 'HEAD' instead of the latest tagged version]"
|
||||
"--freeze[Store 'frozen' hashes in 'rev' instead of tag names]"
|
||||
"*--repo[Only update this repository -- may be specified multiple times]:repos:"
|
||||
{-j,--jobs}"[Number of threads to use]:jobs"
|
||||
)
|
||||
|
||||
_pre_commit_clean_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
)
|
||||
|
||||
_pre_commit_gc_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
)
|
||||
|
||||
_pre_commit_help_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
":Command to show help for.:"
|
||||
)
|
||||
|
||||
_pre_commit_init_templatedir_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
|
||||
"--no-allow-missing-config[Assume cloned repos should have a 'pre-commit' config]"
|
||||
"*"{-t,--hook-type}"[which hook type to install]:hook_types:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg)"
|
||||
":The directory in which to write the hook script.:_files -/"
|
||||
)
|
||||
|
||||
_pre_commit_install_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
|
||||
{-f,--overwrite}"[Overwrite existing hooks / remove migration mode]"
|
||||
"--install-hooks[Whether to install hook environments for all environments in the config file]"
|
||||
{-t,--hook-type}"[which hook type to install]:hook_type:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg)"
|
||||
"--allow-missing-config[Hook scripts will permit a missing configuration file]"
|
||||
)
|
||||
|
||||
_pre_commit_install_hooks_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
|
||||
)
|
||||
|
||||
_pre_commit_migrate_config_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
|
||||
)
|
||||
|
||||
_pre_commit_run_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
|
||||
{--verbose,-v}"[ produce hook output independent of success]"
|
||||
{--all-files,-a}"[Run on all the files in the repo]"
|
||||
"--files[Specific filenames to run hooks on]:files:_files"
|
||||
"--show-diff-on-failure[When hooks fail, run 'git diff' directly afterward]"
|
||||
"--hook-stage[The stage during which the hook is fired]:hook_stage:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg manual)"
|
||||
"--remote-branch[Remote branch ref used by 'git push']:remote_branch:"
|
||||
"--local-branch[Local branch ref used by 'git push']:local_branch:"
|
||||
{--from-ref,--source,-s}"[the original ref in a 'from_ref...to_ref' diff expression]:from_ref:"
|
||||
{--to-ref,--origin,-o}"[the destination ref in a 'from_ref...to_ref' diff expression]:to_ref:"
|
||||
"--pre-rebase-upstream[the upstream from which the series was forked]:pre_rebase_upstream"
|
||||
"--pre-rebase-branch[the branch being rebased and is not set when rebasing the current branch]:pre_rebase_branch"
|
||||
"--commit-msg-filename[Filename to check when running during 'commit-msg']:commit_msg_filename:"
|
||||
"--prepare-commit-message-source[Source of the commit message]:prepare_commit_message_source:"
|
||||
"--commit-object-name[Commit object name]:commit_object_name:"
|
||||
"--remote-name[Remote name used by 'git push']:remote_name:"
|
||||
"--remote-url[Remote url used by 'git push']:remote_url:"
|
||||
"--checkout-type[Indicates whether the checkout was a branch checkout or a file checkout]:checkout_type:((0\:file\ checkout 1\:branch\ checkout))"
|
||||
"--is-squash-merge[During a post-merge hook, indicates whether the merge was a squash merge]:is_squash_merge:"
|
||||
"--rewrite-command[During a post-rewrite hook, specifies the command that invoked the rewrite]:rewrite_command:"
|
||||
":A single hook-id to run:"
|
||||
)
|
||||
|
||||
_pre_commit_sample_config_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
)
|
||||
|
||||
_pre_commit_try_repo_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
|
||||
{--ref,--rev}"[Manually select a rev to run against, otherwise 'HEAD']:ref:"
|
||||
{--verbose,-v}"[verbose output]"
|
||||
{--all-files,-a}"[Run on all the files in the repo]"
|
||||
"--files[Specific filenames to run hooks on]:files:_files"
|
||||
"--show-diff-on-failure[When hooks fail, run 'git diff' directly afterward]"
|
||||
"--hook-stage[The stage during which the hook is fired]:hook_stage:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg manual)"
|
||||
"--remote-branch[Remote branch ref used by 'git push']:remote_branch:"
|
||||
"--local-branch[Local branch ref used by 'git push']:local_branch:"
|
||||
{--from-ref,--source,-s}"[the original ref in a 'from_ref...to_ref' diff expression]:from_ref:"
|
||||
{--to-ref,--origin,-o}"[the destination ref in a 'from_ref...to_ref' diff expression]:to_ref:"
|
||||
"--pre-rebase-upstream[the upstream from which the series was forked]:pre_rebase_upstream"
|
||||
"--pre-rebase-branch[the branch being rebased and is not set when rebasing the current branch]:pre_rebase_branch"
|
||||
"--commit-msg-filename[Filename to check when running during 'commit-msg']:commit_msg_filename:"
|
||||
"--prepare-commit-message-source[Source of the commit message]:prepare_commit_message_source:"
|
||||
"--commit-object-name[Commit object name]:commit_object_name:"
|
||||
"--remote-name[Remote name used by 'git push']:remote_name:"
|
||||
"--remote-url[Remote url used by 'git push']:remote_url:"
|
||||
"--checkout-type[Indicates whether the checkout was a branch checkout or a file checkout]:checkout_type:((0\:file\ checkout 1\:branch\ checkout))"
|
||||
"--is-squash-merge[During a post-merge hook, indicates whether the merge was a squash merge]:is_squash_merge:"
|
||||
"--rewrite-command[During a post-rewrite hook, specifies the command that invoked the rewrite]:rewrite_command:"
|
||||
":Repository to source hooks from.:"
|
||||
":A single hook-id to run:"
|
||||
)
|
||||
|
||||
_pre_commit_uninstall_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
{-c,--config}"[Path to alternate config file]:config:_files -g '*.yaml'"
|
||||
"*"{-t,--hook-type}"[which hook type to uninstall]:hook_types:(commit-msg post-checkout post-commit post-merge post-rewrite pre-commit pre-merge-commit pre-push pre-rebase prepare-commit-msg)"
|
||||
)
|
||||
|
||||
_pre_commit_validate_config_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
"(*)::filenames:_files"
|
||||
)
|
||||
|
||||
_pre_commit_validate_manifest_options=(
|
||||
"(- : *)"{-h,--help}"[show this help message and exit]"
|
||||
"--color[Whether to use color in output. Defaults to 'auto']:color:(auto always never)"
|
||||
"(*)::filenames:_files"
|
||||
)
|
||||
|
||||
_pre_commit() {
|
||||
local context state line curcontext="$curcontext" one_or_more='(-)*' reminder='(*)'
|
||||
|
||||
if ((${_pre_commit_options[(I)${(q)one_or_more}*]} + ${_pre_commit_options[(I)${(q)reminder}*]} == 0)); then # noqa: E501
|
||||
_pre_commit_options+=(': :_pre_commit_commands' '*::: :->pre-commit')
|
||||
_pre_commit_git_remote_branches() {
|
||||
if (( $+commands[git] )); then
|
||||
local -a remote_branches=(${(f)"$(git branch -a 2>/dev/null | \grep 'remotes/' | \grep -v HEAD | awk -F/ '{print $NF}' | uniq)"})
|
||||
_values 'branch' $remote_branches
|
||||
fi
|
||||
}
|
||||
|
||||
_pre_commit_git_local_branches() {
|
||||
if (( $+commands[git] )); then
|
||||
local -a local_branches=(${(f)"$(git branch 2>/dev/null | cut -c3-)"})
|
||||
_values 'branch' $local_branches
|
||||
fi
|
||||
}
|
||||
|
||||
_pre_commit_git_remotes() {
|
||||
if (( $+commands[git] )); then
|
||||
local -a remote_names=(${(f)"$(git remote 2>/dev/null)"})
|
||||
_values 'remote' $remote_names
|
||||
fi
|
||||
}
|
||||
|
||||
_pre_commit_commit_types() {
|
||||
local -a types=(
|
||||
'0:retrieving a file from the index'
|
||||
'1:changing branches'
|
||||
)
|
||||
|
||||
_describe 'commit types' types
|
||||
}
|
||||
|
||||
_pre_commit_git_refs() {
|
||||
if (( $+commands[git] )); then
|
||||
local -a refs=(${(f)"$(git branch -a 2>/dev/null | \grep -v HEAD | cut -c3- | sed 's/^remotes\///')"})
|
||||
_values 'ref' $refs
|
||||
fi
|
||||
_arguments -C $_pre_commit_options
|
||||
|
||||
case $state in
|
||||
pre-commit)
|
||||
words=($line[1] "${words[@]}")
|
||||
(( CURRENT += 1 ))
|
||||
curcontext="${curcontext%:*:*}:_pre_commit-$line[1]:"
|
||||
case $line[1] in
|
||||
autoupdate) _arguments -C $_pre_commit_autoupdate_options ;;
|
||||
clean) _arguments -C $_pre_commit_clean_options ;;
|
||||
gc) _arguments -C $_pre_commit_gc_options ;;
|
||||
help) _arguments -C $_pre_commit_help_options ;;
|
||||
init-templatedir) _arguments -C $_pre_commit_init_templatedir_options ;;
|
||||
install) _arguments -C $_pre_commit_install_options ;;
|
||||
install-hooks) _arguments -C $_pre_commit_install_hooks_options ;;
|
||||
migrate-config) _arguments -C $_pre_commit_migrate_config_options ;;
|
||||
run) _arguments -C $_pre_commit_run_options ;;
|
||||
sample-config) _arguments -C $_pre_commit_sample_config_options ;;
|
||||
try-repo) _arguments -C $_pre_commit_try_repo_options ;;
|
||||
uninstall) _arguments -C $_pre_commit_uninstall_options ;;
|
||||
validate-config) _arguments -C $_pre_commit_validate_config_options ;;
|
||||
validate-manifest) _arguments -C $_pre_commit_validate_manifest_options ;;
|
||||
esac
|
||||
esac
|
||||
}
|
||||
|
||||
typeset -A opt_args
|
||||
_pre_commit "$@"
|
||||
|
||||
# Local Variables:
|
||||
|
|
|
|||
Loading…
Reference in New Issue