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
# 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 \
-o o:vV \
--long arch:,help,inject-ssh-identity:,install:,no-warn-if-partition,output:,verbose,version \
-o "$shortopts" \
--long "$longopts" \
-n $program -- "$@"`
if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments"
@@ -92,6 +94,15 @@ while true; do
-V|--version)
echo "$program $version"
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
break;;

View File

@@ -22,9 +22,12 @@ unset CDPATH
program="virt-p2v-make-kickstart"
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 \
-o o:vV \
--long help,inject-ssh-identity:,install:,output:,proxy:,verbose,version \
-o "$shortopts" \
--long "$longopts" \
-n $program -- "$@"`
if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments"
@@ -68,11 +71,22 @@ while true; do
set +x
verbose=1
shift;;
# help etc.
--help)
usage 0;;
-V|--version)
echo "$program $version"
exit 0;;
--help)
usage 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
break;;

View File

@@ -22,9 +22,12 @@ unset CDPATH
program="virt-p2v-make-kiwi"
version="@PACKAGE_VERSION@"
# Parse the command line arguments.
shortopts=o:V
longopts=help,inject-ssh-identity:,long-options,output:,short-options,version
TEMP=`getopt \
-o o:V \
--long help,inject-ssh-identity:,output:,version \
-o "$shortopts" \
--long "$longopts" \
-n $program -- "$@"`
if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments"
@@ -52,11 +55,22 @@ while true; do
-o|--output)
output="$2"
shift 2;;
# help etc.
--help)
usage 0;;
-V|--version)
echo "$program $version"
exit 0;;
--help)
usage 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
break;;