Commit acd35ab1 authored by Alessandro Elias's avatar Alessandro Elias

Merge branch 'issue/498' into 'develop'

SCRUM#498: Improve argument parsing and help

See merge request !7
parents 9afd4a68 00b3ce20
......@@ -20,30 +20,50 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
_HELP=false
_DIST="nodistro"
_ARCH="amd64"
if [ "$(id -u)" != "0" ]; then
echo You must have more power to run this script
exit -1
while true; do
case "$1" in
-h | --help ) _HELP=true; shift ;;
-d | --distro ) _DIST=$2; shift; shift ;;
-a | --arch ) _ARCH=$2; shift; shift ;;
-* ) echo "Unrecognized option. Try with --help."; exit 1 ;;
* ) break ;;
esac
done
if [ ${_HELP} = true ]; then
echo "Usage: sudo $0 [OPTION] [ARGUMENT]..."
echo ""
echo "Examples:"
echo " sudo $0 --distro le6/testing # Generate default arch (amd64) le6 iso image"
echo " sudo $0 -d le6/testing -a i386 # Generate i386 architecture le6 iso image"
echo ""
echo "Options:"
echo " -h, --help Show this help list"
echo " -d, --distro [DIST] Select iso image's distro"
echo " -a, --arch [amd64 | i386] Select iso image's architecture"
exit 2
fi
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "Usage: $0 [dist] [arch]"
echo "Argument [arch] is optional. Default architecture: amd64"
if [ ${_DIST} = "nodistro" ]; then
echo "No distro. Try with --help."
exit 1
fi
if [ "$1" == '--help' ]; then
echo "Usage: $0 [dist] [arch]"
echo "Argument [arch] is optional. Default architecture: amd64"
exit 2
fi
_DIST=$1
if [ ${_ARCH} != "amd64" -a ${_ARCH} != "i386" ]; then
echo "Unrecognized architecture. Try with --help."
exit 1
fi
if [ $# -ne 2 ]; then
_ARCH="amd64"
else
_ARCH=$2
if [ "$(id -u)" != "0" ]; then
echo "You must have more power to run this script. Are you root?"
exit -1
fi
export PREFIX=$(pwd)
source ${PREFIX}/conf/$_DIST/create-iso.conf \
|| log ERROR "configuration file not found for dist: \"${_DIST}\""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment