saturnin.skel 1.6KB

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