From 2c0f6f7c6b34107d828d30e11d116ec24c934b1b Mon Sep 17 00:00:00 2001 From: David Moc Date: Sun, 17 May 2026 01:35:00 +0200 Subject: Updated the readme and added a manpage and bash completion. Signed-off-by: David Moc --- build.sh | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 4 deletions(-) (limited to 'build.sh') diff --git a/build.sh b/build.sh index 128016e..e30ab7d 100755 --- a/build.sh +++ b/build.sh @@ -1,12 +1,105 @@ #!/usr/bin/env sh set -e +usage() { + echo "Usage: $0 [--shell fish|bash|none|all] [--no-man]" +} + +requested_shell= +install_man=true + +while [ "$#" -gt 0 ]; do + case "$1" in + --shell) + requested_shell=${2:-} + shift 2 + ;; + --shell=*) + requested_shell=${1#--shell=} + shift + ;; + --no-man) + install_man=false + shift + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "Unknown option: $1" >&2 + usage >&2 + exit 1 + ;; + esac +done + cabal build exe:tasker bin=$(cabal list-bin exe:tasker) -sudo install -Dm755 "$bin" /usr/local/bin/tasker -sudo install -Dm644 tasker.fish /usr/share/fish/vendor_completions.d/tasker.fish +sudo install -Dm755 "$bin" /usr/local/bin/tasker +echo "Installed $bin -> /usr/local/bin/tasker" + +detect_shell() { + if [ -n "$requested_shell" ]; then + echo "$requested_shell" + else + basename "${SHELL:-}" + fi +} + +install_fish_completion() { + if [ -f tasker.fish ]; then + sudo install -Dm644 tasker.fish \ + /usr/share/fish/vendor_completions.d/tasker.fish + echo "Installed tasker.fish -> /usr/share/fish/vendor_completions.d/tasker.fish" + else + echo "Skipped fish completion: tasker.fish not found" + fi +} + +install_bash_completion() { + if [ -f tasker.bash ]; then + sudo install -Dm644 tasker.bash \ + /usr/share/bash-completion/completions/tasker + echo "Installed tasker.bash -> /usr/share/bash-completion/completions/tasker" + else + echo "Skipped bash completion: tasker.bash not found" + fi +} + +install_manpage() { + if [ -f tasker.1 ]; then + sudo install -Dm644 tasker.1 \ + /usr/local/share/man/man1/tasker.1 + sudo mandb 2>/dev/null || true + echo "Installed tasker.1 -> /usr/local/share/man/man1/tasker.1" + else + echo "Skipped manpage: tasker.1 not found" + fi +} + +case "$(detect_shell)" in + fish) + install_fish_completion + ;; + bash) + install_bash_completion + ;; + all) + install_fish_completion + install_bash_completion + ;; + none) + echo "Skipped shell completions" + ;; + *) + echo "Unsupported shell: ${requested_shell:-${SHELL:-unset}}" + echo "Skipped shell completions" + ;; +esac -echo "Installed $bin -> /usr/local/bin/tasker" -echo "Installed tasker.fish -> /usr/share/fish/vendor_completions.d/tasker.fish" +if [ "$install_man" = true ]; then + install_manpage +fi -- cgit v1.2.3