Split hooks into separate files to reduce compiled size

This commit is contained in:
Ethan P
2020-04-08 03:19:58 -07:00
parent a91ee96e6a
commit 03971fe64e
5 changed files with 126 additions and 106 deletions

25
lib/opt_hook_version.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# bat-extras | Copyright (C) 2019 eth-p | MIT License
#
# Repository: https://github.com/eth-p/bat-extras
# Issues: https://github.com/eth-p/bat-extras/issues
# -----------------------------------------------------------------------------
# Option parser hook: --version support.
# This will accept --version, which prints the version information and exits.
hook_version() {
SHIFTOPT_HOOKS+=("__shiftopt_hook__version")
__shiftopt_hook__version() {
if [[ "$OPT" = "--version" ]]; then
printf "%s %s\n\n%s\n%s\n" \
"$PROGRAM" \
"$PROGRAM_VERSION" \
"$PROGRAM_COPYRIGHT" \
"$PROGRAM_HOMEPAGE"
exit 0
fi
return 1
}
}