#!/usr/bin/env zsh source ~/dotfiles/bin/helpers/functions.sh status() { ~/dotfiles/bin/actions/status.sh $@ } update() { ~/dotfiles/bin/actions/update.sh $@ } help() { ~/dotfiles/bin/actions/help.sh $@ } exports() { ~/dotfiles/bin/actions/export.sh $@ } secrets() { ~/dotfiles/bin/actions/secrets.sh $@ } ensure_git_hooks() { # If ~/dotfiles/.git/hooks is a symlink, skip this if [[ -L ~/dotfiles/.git/hooks ]]; then # Let's make sure the symlink is correct if [[ $(readlink ~/dotfiles/.git/hooks) != ~/dotfiles/bin/actions/git ]]; then printfe "%s\n" "yellow" "The ~/dotfiles/.git/hooks symlink is incorrect. Please remove it and run this script again." fi return fi if [[ -d ~/dotfiles/.git/hooks ]]; then rm -rf ~/dotfiles/.git/hooks printfe "%s\n" "yellow" "The ~/dotfiles/.git/hooks directory already exists. We're removing it!" fi ln -s ~/dotfiles/bin/actions/git ~/dotfiles/.git/hooks printfe "%s\n" "green" "Git hooks are now set up!" } ensure_git_hooks # switch case for parameters case $1 in "update") logo update $@ ;; "status") logo continue status $@ ;; "export") logo exports $@ ;; "help"|"--help"|"") help $@ ;; "secrets") secrets $@ ;; term) ~/dotfiles/bin/actions/term.sh $@ ;; *) printfe "%s\n" "red" "Unknown command $1" help $@ ;; esac