summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/prokit.sh18
1 files changed, 16 insertions, 2 deletions
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}" "${@}"