#!/usr/bin/env bash display_help() { cat <&2 echo 'getopt version check failed' exit 1 fi # Parse options GETOPT_PARSE=$(getopt --name "$0" --longoptions help,get-clang-format --options '' -- "$@") if [[ $? -ne 0 ]]; then exit 1 fi eval set -- "$GETOPT_PARSE" while true; do case "$1" in --help) display_help exit ;; --get-clang-format) get_clang_format=true shift ;; --) shift ; break ;; esac done set -eu hooks_dir=$(git rev-parse --git-path hooks) scripts_dir=$(dirname "${BASH_SOURCE[0]}") install --backup --verbose "$scripts_dir/post-commit" "$hooks_dir" install --backup --verbose "$scripts_dir/reformat-files" "$hooks_dir" if [[ "$get_clang_format" == true ]]; then "$scripts_dir/get-clang-format" "$hooks_dir" fi