diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2023-03-26 11:24:31 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2023-03-26 11:24:31 +0200 |
commit | 0e24383d706a91bc9536b1c0827e4209679ce009 (patch) | |
tree | 8d5619d2b6a1215430eeaf32b8540dd6f0ec7b8c /lib | |
parent | 62c1754d67319a726f29814ae717d0148df6c727 (diff) | |
download | dotfiles-0e24383d706a91bc9536b1c0827e4209679ce009.tar.gz |
install: some reafactoring
Diffstat (limited to 'lib')
-rw-r--r-- | lib/funcs.sh | 14 | ||||
-rw-r--r-- | lib/hooks.sh | 13 |
2 files changed, 22 insertions, 5 deletions
diff --git a/lib/funcs.sh b/lib/funcs.sh index 585c4aa..66786a0 100644 --- a/lib/funcs.sh +++ b/lib/funcs.sh @@ -114,3 +114,17 @@ debug() { warning() { echo "[WARNING] $@" } + +print_help() { + cat << EOF +USAGE: $1 COMMAND [ARGS] +COMMANDS + install [CONFIG ...] + install configurations. if none are provided, + a selection menu is showm. + add PATH + Add PATH to managed configs + hook HOOK + manually call a hook +EOF +} diff --git a/lib/hooks.sh b/lib/hooks.sh index 8d5fc1d..2256914 100644 --- a/lib/hooks.sh +++ b/lib/hooks.sh @@ -2,17 +2,20 @@ # 1: Name of hook call_hook() { - if [ ! -x "hooks/$1.hook" ]; then - debug "$1.hook was not found. Skipping." + local HOOK="$1" + shift + + if [ ! -x "hooks/$HOOK.hook" ]; then + debug "$HOOK.hook was not found. Skipping." return fi - debug "Running hook $1" + debug "Running hook $HOOK" - hooks/$1.hook 2>&1 | (while read line; do echo [hook: $1] $line; done) + hooks/$HOOK.hook 2>&1 | (while read line; do echo [hook: $HOOK] $line; done) RET=${PIPESTATUS[0]} if [ $RET -ne 0 ]; then - warning "Hook $1 exitet with code $RET" + warning "Hook $HOOK exitet with code $RET" fi } |