saturnin.skel 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. . <(ffoom init)
  3. mkinipath() {
  4. local userd="__SATURNIN_INI_USER__/ini.d"
  5. local user="__SATURNIN_INI_USER__"
  6. local lcal="__SATURNIN_INI_LOCAL__"
  7. local distd="__SATURNIN_SHARE__/ini.d"
  8. test -d "$userd" && find "$userd" -mindepth 1 -maxdepth 1 -type d
  9. echo "$user"
  10. echo "$lcal"
  11. test -d "$distd" && find "$distd" -mindepth 1 -maxdepth 1 -type d
  12. }
  13. export FFOO_PATH="__SATURNIN_SHARE__/ffoo"
  14. SATURNIN_LIBEXEC="__SATURNIN_LIBEXEC__"
  15. export FFOO_INI_PATH=$(mkinipath | tr '\n' :)
  16. ffoo import exit
  17. ffoo import core
  18. usage() {
  19. usage_is "[-d|-v] command [args...]" \
  20. "help"
  21. }
  22. print_help() {
  23. echo "valid commands:"
  24. echo ""
  25. ls "$SATURNIN_LIBEXEC" \
  26. | sed -e 's/saturnin-/ /'
  27. }
  28. while true; do case $1 in
  29. -d|--debug) export FFOO_DEBUG=true; shift ;;
  30. -v|--verbose) export FFOO_VERBOSE=true; shift ;;
  31. -*) usage; ;;
  32. --*) usage; ;;
  33. --) shift; break ;;
  34. "") usage; ;;
  35. *) break; ;;
  36. esac done
  37. debug -v FFOO_PATH SATURNIN_LIBEXEC FFOO_INI_PATH
  38. debug "\$@=$@"
  39. scmd=$1
  40. shift
  41. case $scmd in
  42. help) print_help; exit $FFOO_EXIT_OK ;;
  43. *)
  44. lexpath="$SATURNIN_LIBEXEC/saturnin-$scmd"
  45. debug -v lexpath
  46. debug "\$@='$@'"
  47. test -x "$lexpath" && exec "$lexpath" "$@"
  48. warn "invalid sub-command: $scmd"
  49. print_help; exit $FFOO_EXIT_USAGE
  50. ;;
  51. esac