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