1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. . <(ffoom init)
  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 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. version_info() {
  30. echo "$(basename $0) (Smart and ready desktop helper) $SATURNIN_VERSION"
  31. exit $FFOO_EXIT_OK
  32. }
  33. while true; do case $1 in
  34. -d|--debug) export FFOO_DEBUG=true; shift ;;
  35. -v|--verbose) export FFOO_VERBOSE=true; shift ;;
  36. --version) version_info ;;
  37. -*) usage; ;;
  38. --*) usage; ;;
  39. --) shift; break ;;
  40. "") usage; ;;
  41. *) break; ;;
  42. esac done
  43. debug -v FFOO_PATH SATURNIN_LIBEXEC FFOO_CONFIG_PATH
  44. debug "\$@=$@"
  45. scmd=$1
  46. shift
  47. case $scmd in
  48. help) print_help; exit $FFOO_EXIT_OK ;;
  49. *)
  50. lexpath="$SATURNIN_LIBEXEC/saturnin-$scmd"
  51. debug -v lexpath
  52. debug "\$@='$@'"
  53. test -x "$lexpath" && exec "$lexpath" "$@"
  54. warn "invalid sub-command: $scmd"
  55. print_help; exit $FFOO_EXIT_USAGE
  56. ;;
  57. esac