apkgrel: fix usage and invalid options and add test
This commit is contained in:
parent
115e41fd1f
commit
3695cd2008
|
@ -73,9 +73,9 @@ do_nothing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat >&2 <<-__EOF__
|
cat <<-__EOF__
|
||||||
$program $program_version - display or bump pkgrel in APKBUILDs
|
$program $program_version - display or bump pkgrel in APKBUILDs
|
||||||
Usage: $program [-z|--zero] [-a|--add] [-g|--clean-git] [-s|--set NUM]
|
usage: $program [-z|--zero] [-a|--add] [-g|--clean-git] [-s|--set NUM]
|
||||||
[-t|--test] [-f|--force] DIR or APKBUILD...
|
[-t|--test] [-f|--force] DIR or APKBUILD...
|
||||||
Options:
|
Options:
|
||||||
-z, --zero Set pkgrel to 0
|
-z, --zero Set pkgrel to 0
|
||||||
|
@ -98,7 +98,7 @@ only_clean_git=
|
||||||
args=$(getopt -o zags:tfqh --long zero,add,clean-git,set:,test,force,quiet,help \
|
args=$(getopt -o zags:tfqh --long zero,add,clean-git,set:,test,force,quiet,help \
|
||||||
-n "$program" -- "$@")
|
-n "$program" -- "$@")
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
usage
|
usage >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
eval set -- "$args"
|
eval set -- "$args"
|
||||||
|
@ -121,7 +121,7 @@ while true; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
usage
|
usage >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env atf-sh
|
||||||
|
|
||||||
|
. $(atf_get_srcdir)/test_env.sh
|
||||||
|
init_tests \
|
||||||
|
apkgrel_usage
|
||||||
|
|
||||||
|
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
|
||||||
|
|
||||||
|
apkgrel_usage_body() {
|
||||||
|
atf_check -o match:"usage" apkgrel -h
|
||||||
|
atf_check -s exit:2 -e match:"usage" apkgrel -Z
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue