dottum-install 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. . "$(sfpath)" || exit 3
  3. shellfu import pretty
  4. shellfu import dottum
  5. shellfu import saturnin
  6. usage() {
  7. mkusage "$@" "[options] VAULT [SUBVAULT]" \
  8. -o \
  9. "-n Do not do anything, just show what would be done" \
  10. "-B Do not replace broken link" \
  11. "-f Do not skip existing links"
  12. }
  13. dottum__route() {
  14. DOTTUM__VAULT=$1; shift
  15. local DOTTUM__SUBVAULTS=()
  16. test -n "$DOTTUM__VAULT" || usage -w "no VAULT?"
  17. test -e "$DOTTUM__VAULT" || die "vault does not exist: $DOTTUM__VAULT"
  18. test -d "$DOTTUM__VAULT" || die "vault is not a directory: $DOTTUM__VAULT"
  19. DOTTUM__SUBVAULTS=("$@")
  20. case $Action in
  21. init) dottum__make_links ;;
  22. explore) dottum__explore ;;
  23. *) saturnin__bug "bad Action: $Action" ;;
  24. esac
  25. }
  26. export LC_ALL=C
  27. main() {
  28. local Action=init
  29. while true; do case $1 in
  30. -n) Action=explore; shift ;;
  31. -B) DOTTUM__CLOBBER_BROKEN=false; shift ;;
  32. -f) DOTTUM__CLOBBER_LINKS=true; shift ;;
  33. -*) usage -w "unknown argument: $1" ;;
  34. *) break ;;
  35. esac done
  36. dottum__route "$@"
  37. }
  38. main "$@"