p2v: Implement --short-options and --long-options in virt-p2v-make-* scripts.

This commit is contained in:
Richard W.M. Jones
2016-08-25 13:08:25 +01:00
parent 2af8d07af6
commit 4df8a099ab
3 changed files with 49 additions and 10 deletions

View File

@@ -36,9 +36,11 @@ else
fi fi
# Parse the command line arguments. # Parse the command line arguments.
shortopts=o:vV
longopts=arch:,help,short-options,inject-ssh-identity:,install:,long-options,no-warn-if-partition,output:,verbose,version
TEMP=`getopt \ TEMP=`getopt \
-o o:vV \ -o "$shortopts" \
--long arch:,help,inject-ssh-identity:,install:,no-warn-if-partition,output:,verbose,version \ --long "$longopts" \
-n $program -- "$@"` -n $program -- "$@"`
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments" echo "$program: problem parsing the command line arguments"
@@ -92,6 +94,15 @@ while true; do
-V|--version) -V|--version)
echo "$program $version" echo "$program $version"
exit 0;; exit 0;;
--short-options)
echo -n "$shortopts" |
@SED@ -e 's/://g' -e 's/\(.\)/-\1\n/g'
exit 0;;
--long-options)
echo "$longopts" |
@SED@ -e 's/,/\n/g' -e 's/:$//mg' -e 's/\(.*\)/--\1/mg' |
grep -v -E -- "--(short|long)-options"
exit 0;;
--) --)
shift shift
break;; break;;

View File

@@ -22,9 +22,12 @@ unset CDPATH
program="virt-p2v-make-kickstart" program="virt-p2v-make-kickstart"
version="@PACKAGE_VERSION@" version="@PACKAGE_VERSION@"
# Parse the command line arguments.
shortopts=o:vV
longopts=help,inject-ssh-identity:,install:,long-options,output:,proxy:,short-options,verbose,version
TEMP=`getopt \ TEMP=`getopt \
-o o:vV \ -o "$shortopts" \
--long help,inject-ssh-identity:,install:,output:,proxy:,verbose,version \ --long "$longopts" \
-n $program -- "$@"` -n $program -- "$@"`
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments" echo "$program: problem parsing the command line arguments"
@@ -68,11 +71,22 @@ while true; do
set +x set +x
verbose=1 verbose=1
shift;; shift;;
# help etc.
--help)
usage 0;;
-V|--version) -V|--version)
echo "$program $version" echo "$program $version"
exit 0;; exit 0;;
--help) --short-options)
usage 0;; echo -n "$shortopts" |
@SED@ -e 's/://g' -e 's/\(.\)/-\1\n/g'
exit 0;;
--long-options)
echo "$longopts" |
@SED@ -e 's/,/\n/g' -e 's/:$//mg' -e 's/\(.*\)/--\1/mg' |
grep -v -E -- "--(short|long)-options"
exit 0;;
--) --)
shift shift
break;; break;;

View File

@@ -22,9 +22,12 @@ unset CDPATH
program="virt-p2v-make-kiwi" program="virt-p2v-make-kiwi"
version="@PACKAGE_VERSION@" version="@PACKAGE_VERSION@"
# Parse the command line arguments.
shortopts=o:V
longopts=help,inject-ssh-identity:,long-options,output:,short-options,version
TEMP=`getopt \ TEMP=`getopt \
-o o:V \ -o "$shortopts" \
--long help,inject-ssh-identity:,output:,version \ --long "$longopts" \
-n $program -- "$@"` -n $program -- "$@"`
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments" echo "$program: problem parsing the command line arguments"
@@ -52,11 +55,22 @@ while true; do
-o|--output) -o|--output)
output="$2" output="$2"
shift 2;; shift 2;;
# help etc.
--help)
usage 0;;
-V|--version) -V|--version)
echo "$program $version" echo "$program $version"
exit 0;; exit 0;;
--help) --short-options)
usage 0;; echo -n "$shortopts" |
@SED@ -e 's/://g' -e 's/\(.\)/-\1\n/g'
exit 0;;
--long-options)
echo "$longopts" |
@SED@ -e 's/,/\n/g' -e 's/:$//mg' -e 's/\(.*\)/--\1/mg' |
grep -v -E -- "--(short|long)-options"
exit 0;;
--) --)
shift shift
break;; break;;