summaryrefslogtreecommitdiff
path: root/abuild-keygen.in
diff options
context:
space:
mode:
authorDubiousjim <dubiousjim@gmail.com>2013-07-05 00:21:19 -0400
committerNatanael Copa <ncopa@alpinelinux.org>2013-07-09 06:59:30 +0000
commitef9fb52908d3f423e6e537b84f62cb76c7868782 (patch)
treeae6e61c807f98893d84f189468444d5aa04ba3c7 /abuild-keygen.in
parent7b2030a06ad926035fabbad64aac4ddeab0bb602 (diff)
downloadabuild-ef9fb52908d3f423e6e537b84f62cb76c7868782.tar.gz
abuild-ef9fb52908d3f423e6e537b84f62cb76c7868782.tar.bz2
abuild-ef9fb52908d3f423e6e537b84f62cb76c7868782.tar.xz
abuild-ef9fb52908d3f423e6e537b84f62cb76c7868782.zip
various: use long options, rework usages
Diffstat (limited to 'abuild-keygen.in')
-rw-r--r--abuild-keygen.in54
1 files changed, 35 insertions, 19 deletions
diff --git a/abuild-keygen.in b/abuild-keygen.in
index 9b748d3..34af0ee 100644
--- a/abuild-keygen.in
+++ b/abuild-keygen.in
@@ -90,30 +90,46 @@ do_keygen() {
msg ""
}
-# print usage and exit
usage() {
- echo "abuild-keygen $abuild_ver"
- echo "usage: abuild-keygen [-ih]"
- echo "options:"
- echo " -a Set PACKAGER_PRIVKEY=<generated key> in $abuild_userconf"
- echo " -i Install public key into /etc/apk/keys using sudo"
- echo " -h Show this help"
- echo " -n Non-interactive. Use defaults"
- echo " -q Quiet mode"
- echo ""
- exit 1
+ cat >&2 <<__EOF__
+$prog $abuild_ver - generate signing keys
+Usage: $prog [-a|--append] [-i|--install] [-n]
+Options:
+ -a, --append Set PACKAGER_PRIVKEY=<generated key> in $abuild_userconf
+ -i, --install Install public key into /etc/apk/keys using sudo
+ -n Non-interactive. Use defaults
+ -q, --quiet
+ -h, --help Show this help
+
+__EOF__
}
+append_config=
+install_pubkey=
+non_interactive=
+quiet=
-while getopts "ahinq" opt; do
- case $opt in
- a) append_config=yes;;
- h) usage;;
- i) install_pubkey=yes;;
- n) non_interactive=yes;;
- q) quiet=-quiet;;
+args=`getopt -o ainqh --long append,install,quiet,help -n "$prog" -- "$@"`
+if [ $? -ne 0 ]; then
+ usage
+ exit 2
+fi
+eval set -- "$args"
+while true; do
+ case $1 in
+ -a|--append) append_config=1;;
+ -i|--install) install_pubkey=1;;
+ -n) non_interactive=yes;;
+ -q|--quiet) quiet=1;; # suppresses msg
+ -h|--help) usage; exit;;
+ --) shift; break;;
+ *) exit 1;; # getopt error
esac
+ shift
done
-shift $(( $OPTIND - 1))
+if [ $# -ne 0 ]; then
+ usage
+ exit 2
+fi
do_keygen