aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorDavid Moc <personal@cdatgoose.org>2026-05-17 01:35:00 +0200
committerDavid Moc <personal@cdatgoose.org>2026-05-17 01:35:00 +0200
commit2c0f6f7c6b34107d828d30e11d116ec24c934b1b (patch)
treec571ae0dc93fefb22c3bf5af481b72c28da89e92 /build.sh
parentb0d5cb5d9d3607add2932b03af50a2a6c18f1721 (diff)
Updated the readme and added a manpage and bash completion.HEADmaster
Signed-off-by: David Moc <personal@cdatgoose.org>
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh101
1 files changed, 97 insertions, 4 deletions
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