[pkg-haskell-tools] 03/03: dht upload: Added 'proper' option parsing
Sven Bartscher
kritzefitz at moszumanska.debian.org
Mon Aug 7 23:24:17 UTC 2017
This is an automated email from the git hooks/post-receive script.
kritzefitz pushed a commit to branch master
in repository pkg-haskell-tools.
commit 9f5d1a09dc218f6baa68521ea3a7405cb14a589a
Author: Sven Bartscher <sven.bartscher at credativ.de>
Date: Mon Aug 7 19:21:25 2017 -0400
dht upload: Added 'proper' option parsing
Options are now parsed using GNU getopt. This gives more intuitive
parsing behavior and is more flexible when new options are added in
the future.
---
scripts/upload | 78 ++++++++++++++++++++++++++++++----------------------------
1 file changed, 40 insertions(+), 38 deletions(-)
diff --git a/scripts/upload b/scripts/upload
index aa03c08..7383ac0 100755
--- a/scripts/upload
+++ b/scripts/upload
@@ -2,34 +2,37 @@
set -e
-if [ "$1" = "--help" ]
-then
- echo "upload - Uploads, tags and pushes"
- echo
- echo "Usage: dht upload [-h HOST] [foo.changes]"
- echo
- echo "Signs the .changes file and the corresponding .dsc file in a temporary"
- echo "location (to avoid touching the original files), uploads them to the archive"
- echo "using \"dput\", tags them in the repository and pushes the tag."
- echo
- echo "If the -h parameter is specified, upload to HOST, rather than the dput"
- echo "\"default_host\". If mass-uploading, it is suggested to use \"ssh-upload\" for"
- echo "robustness (see the discussion in #833536)."
- echo
- echo "If no changes file is given, but the script is run in a debian source package,"
- echo "it checks the parent directory for an appropriately named changes file, just"
- echo "like debrelease(1) would do."
- echo
- echo "Checks that the distribution is not UNRELEASED and that the tag does"
- echo "not exist already."
- echo
- exit 0
-fi
-
+args=`getopt -n "$0" -o "h:" -l "help,manpage" -- "$@"`
+eval set -- "$args"
-if [ "$1" = "--manpage" ]
-then
-cat <<'__END__'
+for i
+do
+ shift
+ case $i in
+ "--help")
+ echo "upload - Uploads, tags and pushes"
+ echo
+ echo "Usage: dht upload [-h HOST] [foo.changes]"
+ echo
+ echo "Signs the .changes file and the corresponding .dsc file in a temporary"
+ echo "location (to avoid touching the original files), uploads them to the archive"
+ echo "using \"dput\", tags them in the repository and pushes the tag."
+ echo
+ echo "If the -h parameter is specified, upload to HOST, rather than the dput"
+ echo "\"default_host\". If mass-uploading, it is suggested to use \"ssh-upload\" for"
+ echo "robustness (see the discussion in #833536)."
+ echo
+ echo "If no changes file is given, but the script is run in a debian source package,"
+ echo "it checks the parent directory for an appropriately named changes file, just"
+ echo "like debrelease(1) would do."
+ echo
+ echo "Checks that the distribution is not UNRELEASED and that the tag does"
+ echo "not exist already."
+ echo
+ exit 0
+ ;;
+ "--manpage")
+ cat <<'__END__'
Usage: dht upload [-h HOST] [foo.changes]
Signs the `.changes` file and the corresponding `.dsc` file in a temporary
@@ -47,17 +50,16 @@ like debrelease(1) would do.
Checks that the distribution is not `UNRELEASED` and that the tag does
not exist already.
__END__
- exit 0;
-fi
-
-if [ "$1" = "-h" ]
-then
- host="$2"
- shift
- shift
-else
- host=""
-fi
+ exit 0;
+ ;;
+ "-h")
+ host="$1"
+ ;;
+ "--")
+ break;
+ ;;
+ esac
+done
changes="$@"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/pkg-haskell-tools.git
More information about the Pkg-haskell-commits
mailing list