saturnin.skel 1.8KB

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