From 83e2e8e049c157743f50f618c71923a016645551 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Sun, 27 Aug 2023 12:53:28 -0500 Subject: fix: simplify install script --- install.sh | 126 ++++----------------------------- nvim/.config/nvim/lua/tobyvin/lazy.lua | 1 - nvim/install.sh | 9 +-- 3 files changed, 15 insertions(+), 121 deletions(-) diff --git a/install.sh b/install.sh index 2d14b2e..338b976 100755 --- a/install.sh +++ b/install.sh @@ -1,12 +1,11 @@ #!/bin/sh -# shellcheck source-path=SCRIPTDIR SCRIPT="$(basename "$0")" SCRIPT_DIR="$(dirname -- "$(readlink -f -- "$0")")" INSTALL_DIR="$(dirname "$SCRIPT_DIR")" -long='install,clean,clean-only,no,simulate,verbose,help' -short='icCnvh' +long='clean-only,help' +short='ch' if ! opts="$(getopt -o $short -l $long -n "$SCRIPT" -- "$@")"; then exit 1 @@ -20,88 +19,28 @@ help() { Toby Vincent $SCRIPT - Installer script. Basically just a wrapper around GNU stow with a few niceties. Running with - no arguments and no '--clean-only' flag with stow all packages, with the exception of - platform specific packages, e.g. 'wsl'. + Installer script that is a simple wrapper around GNU stow that removes broken symlinks + found in $INSTALL_DIR, stows all packages, and runs all ./*/install.sh scripts. USAGE: - $SCRIPT [OPTION ...] [PACKAGE ...] + $SCRIPT [OPTION ...] OPTIONS: - -i, --install After stowing, run any '/install.sh' in packages. - -c, --clean Remove broken symlinks found in $INSTALL_DIR for proceeding. - -C, --clean-only Like --clean, but will exit after cleaning. - -n, --no, --simulate Do not actually make any filesystem changes. - -v, --verbose Increase verbosity. -h, --help Show this help. EOF } -say() { - printf "%s: %s\n" "$SCRIPT" "$@" -} - -say_verbose() { - # shellcheck disable=2086 - if [ $verbose -gt 0 ]; then - say "$@" - fi -} - -say_err() { - say "$@" >&2 -} - -err() { - say_err "ERROR: $*" - exit 1 -} - -err_help() { - help - err "$*" -} - -need() { - for need_cmd in "$@"; do - if ! command -v "$need_cmd" >/dev/null 2>&1; then - err "need $need_cmd (command not found)" - fi - done -} - -clean=false clean_only=false -verbose=0 -simulate="" -install=false while true; do case "$1" in -h | --help) help exit 0 ;; - -v | --verbose) - verbose=$((verbose + 1)) - shift - ;; - -i | --install) - install=true - shift - ;; - -c | --clean) - clean=true - shift - ;; - -C | --clean-only) - clean=true + -c | --clean-only) clean_only=true shift ;; - -n | --no | --simulate) - simulate='-n' - shift - ;; --) shift break @@ -112,53 +51,14 @@ while true; do esac done -verbose_args="$(head -c $verbose