1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #!/bin/bash
-
- . $(ffoom path) || exit 3
-
- mkconfpath() {
- local userd="__SATURNIN_CONFIG_USER__/ini.d"
- local user="__SATURNIN_CONFIG_USER__"
- local lcal="__SATURNIN_CONFIG_LOCAL__"
- local distd="__SATURNIN_SHARE__/ini.d"
- test -d "$userd" && find -L "$userd" -mindepth 1 -maxdepth 1 -type d
- echo "$user"
- echo "$lcal"
- test -d "$distd" && find -L "$distd" -mindepth 1 -maxdepth 1 -type d
- }
-
- export FFOO_PATH="__SATURNIN_SHARE__/ffoo"
- SATURNIN_LIBEXEC="__SATURNIN_LIBEXEC__"
- export FFOO_CONFIG_PATH=$(mkconfpath | tr '\n' :)
- export SATURNIN_VERSION="__VERSION__"
- export SATURNIN_CACHE_HOME="__SATURNIN_CACHE_HOME__"
-
- ffoo import exits
- ffoo import pretty
-
- usage() {
- usage_is "[-d|-v] command [args...]" \
- "help" \
- "--version"
- }
-
- print_help() {
- echo ""
- echo "valid sub-commands:"
- echo ""
- find "$SATURNIN_LIBEXEC" \
- -mindepth 1 \
- -maxdepth 1 \
- -executable \
- | sed -e 's/.*saturnin-/ /' \
- | sort
- return "$FFOO_EXIT_OK"
- }
-
- version_info() {
- echo "$(basename $0) (Smart and ready desktop helper) $SATURNIN_VERSION"
- exit $FFOO_EXIT_OK
- }
-
- while true; do case $1 in
- -d|--debug) export FFOO_DEBUG=true; shift ;;
- -v|--verbose) export FFOO_VERBOSE=true; shift ;;
- --version) version_info ;;
- --version-semver) echo "$SATURNIN_VERSION"; exit ;;
- -*) usage; ;;
- --*) usage; ;;
- --) shift; break ;;
- "") usage; ;;
- *) break; ;;
- esac done
-
- debug -v FFOO_PATH SATURNIN_LIBEXEC FFOO_CONFIG_PATH
- debug "\$*='$*'"
-
- SATURNIN_SUBCOMMAND="$1"
- shift
-
- case "$SATURNIN_SUBCOMMAND" in
- help) print_help; exit $FFOO_EXIT_OK ;;
- *)
- lexpath="$SATURNIN_LIBEXEC/saturnin-$SATURNIN_SUBCOMMAND"
- debug -v lexpath
- debug "\$*='$*'"
- test -x "$lexpath" && exec "$lexpath" "$@"
- warn "invalid sub-command: $SATURNIN_SUBCOMMAND"
- print_help; exit $FFOO_EXIT_USAGE
- ;;
- esac
|