diff options
| author | David Moc <personal@cdatgoose.org> | 2026-05-17 01:35:00 +0200 |
|---|---|---|
| committer | David Moc <personal@cdatgoose.org> | 2026-05-17 01:35:00 +0200 |
| commit | 2c0f6f7c6b34107d828d30e11d116ec24c934b1b (patch) | |
| tree | c571ae0dc93fefb22c3bf5af481b72c28da89e92 /build.sh | |
| parent | b0d5cb5d9d3607add2932b03af50a2a6c18f1721 (diff) | |
Signed-off-by: David Moc <personal@cdatgoose.org>
Diffstat (limited to 'build.sh')
| -rwxr-xr-x | build.sh | 101 |
1 files changed, 97 insertions, 4 deletions
@@ -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 |
