shell dot on steroids https://pagure.io/shellfu

ffoom.skel 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. . __FFOO_DIR__/ffoo.sh
  3. ffoo import core
  4. usage() {
  5. usage_is \
  6. "[-d] --version[-major|-minor|-patch|-full|-proper|-meta]" \
  7. "[-d] init" \
  8. "[-d] init_path" \
  9. "[-d] lsfun [module]" \
  10. "[-d] lsmod [pattern]" \
  11. "[-d] catfun module.function"
  12. }
  13. version_info_full() {
  14. echo "$(basename $0) (Fast Foo bash library) $FFOO_VERSION"
  15. echo
  16. echo "install path: __FFOO_DIR__"
  17. }
  18. version_info() {
  19. debug "1='$1'"
  20. local proper=$(cut -d+ -f1 <<<"$FFOO_VERSION")
  21. local meta=$(cut -d+ -f2- <<<"$FFOO_VERSION")
  22. case $1 in
  23. -full) echo "$FFOO_VERSION" ;;
  24. -proper) echo "$proper" ;;
  25. -major) echo $(cut -d. -f1 <<<"$proper");;
  26. -minor) echo $(cut -d. -f2 <<<"$proper");;
  27. -patch) echo $(cut -d. -f3 <<<"$proper");;
  28. -meta) echo "$meta";;
  29. *) usage ;;
  30. esac
  31. }
  32. while true; do case $1 in
  33. init) cat "__FFOO_DIR__/ffoo.sh"; exit $? ;;
  34. init_path) echo "__FFOO_DIR__/ffoo.sh"; exit 0 ;;
  35. lsmod) ffoo _list_modules "$2"; exit $? ;;
  36. lsfun) ffoo _list_functions "$2"; exit $? ;;
  37. catfun) ffoo _cat_function "$2"; exit $? ;;
  38. -d|--debug) FFOO_DEBUG=true; shift ;;
  39. --version) version_info_full; exit 0 ;;
  40. --version*) version_info "${1:9}"; exit 0 ;;
  41. *) usage ;;
  42. esac done