#!/bin/bash . <(ffoom init) mkconfpath() { local userd="__SATURNIN_CONFIG_USER__/conf.d" local user="__SATURNIN_CONFIG_USER__" local lcal="__SATURNIN_CONFIG_LOCAL__" local distd="__SATURNIN_SHARE__/conf.d" test -d "$userd" && find "$userd" -mindepth 1 -maxdepth 1 -type d echo "$user" echo "$lcal" test -d "$distd" && find "$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__" ffoo import exits ffoo import pretty usage() { usage_is "[-d|-v] command [args...]" \ "help" \ "--version" } print_help() { echo "valid commands:" echo "" ls "$SATURNIN_LIBEXEC" \ | sed -e 's/saturnin-/ /' } 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 ;; -*) usage; ;; --*) usage; ;; --) shift; break ;; "") usage; ;; *) break; ;; esac done debug -v FFOO_PATH SATURNIN_LIBEXEC FFOO_CONFIG_PATH debug "\$@=$@" scmd=$1 shift case $scmd in help) print_help; exit $FFOO_EXIT_OK ;; *) lexpath="$SATURNIN_LIBEXEC/saturnin-$scmd" debug -v lexpath debug "\$@='$@'" test -x "$lexpath" && exec "$lexpath" "$@" warn "invalid sub-command: $scmd" print_help; exit $FFOO_EXIT_USAGE ;; esac