chiark / gitweb /
ubuntu-paste: convert to python3/argparse/requests
[bin.git] / rosetta-merge-all
index 98627a2..6740bbc 100755 (executable)
@@ -1,7 +1,48 @@
 #! /bin/sh
-if [ "$1" = --apply ]; then
-       shift
-       for x in *.po; do rosetta-merge --apply $1 ${x%.*}; done
+
+APPLY=false
+
+usage () {
+       [ "$1" = 0 ] || exec >&2
+       echo "Usage: $0 [--apply] [--keep-old] [--prefix PREFIX] SOURCE"
+       exit "$1"
+}
+
+die_getopt () {
+       echo "getopt failed" >&2
+       exit 1
+}
+
+parse_opts () {
+       eval set -- "$(getopt -o '' -l apply,keep-old,prefix:,help -- "$@")"
+       while :; do
+               case $1 in
+                       --apply)
+                               APPLY=:
+                               shift
+                               ;;
+                       --keep-old)
+                               shift
+                               ;;
+                       --prefix)
+                               shift 2
+                               ;;
+                       --help)
+                               usage 0
+                               shift
+                               ;;
+                       --)     shift; break ;;
+                       *)      die_getopt ;;
+               esac
+       done
+}
+
+[ "$1" ] || usage 1
+
+parse_opts "$@"
+
+if $APPLY; then
+       for x in *.po; do rosetta-merge "$@" ${x%.*}; done
 else
-       for x in *.po; do rosetta-merge $1 ${x%.*} | view -; done
+       for x in *.po; do rosetta-merge "$@" ${x%.*} | view -; done
 fi