saturnin.skel 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. . $(ffoom path)
  3. mkconfpath() {
  4. local userd="__SATURNIN_CONFIG_USER__/conf.d"
  5. local user="__SATURNIN_CONFIG_USER__"
  6. local lcal="__SATURNIN_CONFIG_LOCAL__"
  7. local distd="__SATURNIN_SHARE__/conf.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=$(mkconfpath | tr '\n' :)
  16. export SATURNIN_VERSION="__VERSION__"
  17. export SATURNIN_CACHE_HOME="__SATURNIN_CACHE_HOME__"
  18. ffoo import exits
  19. ffoo import pretty
  20. usage() {
  21. usage_is "[-d|-v] command [args...]" \
  22. "help" \
  23. "--version"
  24. }
  25. print_help() {
  26. echo ""
  27. echo "valid sub-commands:"
  28. echo ""
  29. ls "$SATURNIN_LIBEXEC" \
  30. | sed -e 's/saturnin-/ /'
  31. }
  32. version_info() {
  33. echo "$(basename $0) (Smart and ready desktop helper) $SATURNIN_VERSION"
  34. exit $FFOO_EXIT_OK
  35. }
  36. while true; do case $1 in
  37. -d|--debug) export FFOO_DEBUG=true; shift ;;
  38. -v|--verbose) export FFOO_VERBOSE=true; shift ;;
  39. --version) version_info ;;
  40. -*) usage; ;;
  41. --*) usage; ;;
  42. --) shift; break ;;
  43. "") usage; ;;
  44. *) break; ;;
  45. esac done
  46. debug -v FFOO_PATH SATURNIN_LIBEXEC FFOO_CONFIG_PATH
  47. debug "\$@=$@"
  48. scmd=$1
  49. shift
  50. case $scmd in
  51. help) print_help; exit $FFOO_EXIT_OK ;;
  52. *)
  53. lexpath="$SATURNIN_LIBEXEC/saturnin-$scmd"
  54. debug -v lexpath
  55. debug "\$@='$@'"
  56. test -x "$lexpath" && exec "$lexpath" "$@"
  57. warn "invalid sub-command: $scmd"
  58. print_help; exit $FFOO_EXIT_USAGE
  59. ;;
  60. esac