#!/usr/bin/env sh

set -e
set -ux

bashdest="${HOME}/.local/share/bash-completion"
xbindest="${HOME}/.local/bin"
mandest="${HOME}/.local/share/man/man1"

run() {
  echo '$' "$@"
  "$@"
}

make_dir() {
  run mkdir -p "$1"
}

# logparse
logparseurl=https://raw.githubusercontent.com/Forza-tng/logparse/refs/heads/main
curl -fsSL "${logparseurl}"/logparse -o "${xbindest}"/logparse

# pa
# if command -v pa >/dev/null 2>&1; then
#   # git clone -q https://github.com/biox/pa.git
#   paurl=https://raw.githubusercontent.com/biox/pa/refs/heads/main
#   curl -fsSL "${paurl}"/pa -o "${xbindest}"/pa
# fi

# todo - https://git.sr.ht/~xan/todo-cli
if test -x "${HOME%/}"/.local/bin/todo; then
  todourl=https://git.sr.ht/~xan/todo-cli/blob/main
  curl -fsSL "${todourl}"/todo -o "${xbindest}"/todo
  curl -fsSL "${todourl}"/contrib/completions/todo.bash -o "${bashdest}"/todo
  curl -fsSL "${todourl}"/todo.1 -o "${mandest}"/todo.1
fi

{
  set +ux
} 2>/dev/null
