From 304a658035718765ba9a5b7a7df22223fb5631c9 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Wed, 23 Oct 2013 16:50:19 -0400 Subject: prokit: Parse options. --- (limited to 'src') diff --git a/src/prokit.sh b/src/prokit.sh index eec634a..41b250a 100644 --- a/src/prokit.sh +++ b/src/prokit.sh @@ -26,6 +26,7 @@ PACKAGE_NAME='@PACKAGE_NAME@' PACKAGE_VERSION='@PACKAGE_VERSION@' PKGDATADIR='@pkgdatadir@' PKGDATACMDDIR='@pkgdatacmddir@' +OPTSTRING='hV' # Global variables loading_cmd= @@ -66,6 +67,7 @@ use() use locale use cmd +use getopt main() { @@ -74,8 +76,20 @@ main() load_locale load_cmds - cmd="${1}" - shift + get_options "${OPTSTRING}" 'opt_' "${@}" + shift $(($OPTIND - 1)) + + if ${opt_h:-false}; then + cmd='help' + elif ${opt_V:-false}; then + cmd='version' + elif [ ${#} -lt 1 ]; then + cmd_help_main >&2 + exit 1 + else + cmd="${1}" + shift + fi run_cmd "${cmd}" "${@}" -- cgit v0.9.1