summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYvan Roux <yvan.roux@linaro.org>2017-11-10 13:19:06 +0100
committerYvan Roux <yvan.roux@linaro.org>2017-11-10 13:19:06 +0100
commita1e732b98de17e164956d9198bab6a7ff8757726 (patch)
treec88912cd0fe9545ed787c55f9b17c52de4f01858
parent53e4500985b2cc6da783fd07c912e8e2a290a206 (diff)
downloadbackflip-a1e732b98de17e164956d9198bab6a7ff8757726.tar.gz
Add usage.
Change-Id: I6c92771e1217d582e367eaf61d8de1500b2176c1
-rwxr-xr-xbackflip63
1 files changed, 40 insertions, 23 deletions
diff --git a/backflip b/backflip
index 4aad6a7..87a6e53 100755
--- a/backflip
+++ b/backflip
@@ -24,29 +24,6 @@ COLOR=true
TMPDIR=/tmp/$(basename "$0")-$$
PREFIX=${TMPDIR}/backport
-# Arguments
-while getopts "b:r:v:x" options
-do
- case $options in
- r ) REF_BRANCH=$OPTARG
- ;;
- b ) DEV_BRANCH=$OPTARG
- STACKED=true
- ;;
- v ) VERSION=$OPTARG
- REF_BRANCH=linaro-local/gcc-${VERSION}-integration-branch
- ;;
- x ) INTERACTIVE=false
- COLOR=false
- ;;
- esac
-done
-shift $(($OPTIND - 1))
-
-if [ -z ${DEV_BRANCH+x} ]; then
- DEV_BRANCH=${REF_BRANCH}
-fi
-
# Style
if $COLOR; then
NC='\e[0m'
@@ -60,6 +37,11 @@ lines=`perl -E 'say "-" x 80'`
# ==============================================================================
# Functions
# ==============================================================================
+usage() {
+ tool="$(basename "$0")"
+ echo -e "$tool [-v GCC_VERSION] [-r REF_BRANCH] [-b DEV_BRANCH] [-x] REVISION"
+}
+
print_step() {
echo -e "${blue}${lines}\n${red}** ${1}\n${blue}${lines}${NC}\n"
}
@@ -147,6 +129,41 @@ clean() {
exit $1
}
+# Arguments
+while getopts ":b:r:v:x" options
+do
+ case $options in
+ r ) REF_BRANCH=$OPTARG
+ ;;
+ b ) DEV_BRANCH=$OPTARG
+ STACKED=true
+ ;;
+ v ) VERSION=$OPTARG
+ REF_BRANCH=linaro-local/gcc-${VERSION}-integration-branch
+ ;;
+ x ) INTERACTIVE=false
+ COLOR=false
+ ;;
+ \?) print_info "Option -${bold}$OPTARG${NC} Unsupported."
+ exit 1
+ ;;
+ : ) print_info "Option -${bold}$OPTARG${NC} requires an argument."
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [ $# -lt 1 ]; then
+ usage ; exit 1
+fi
+
+shift $(($OPTIND - 1))
+
+if [ -z ${DEV_BRANCH+x} ]; then
+ DEV_BRANCH=${REF_BRANCH}
+fi
+
# ==============================================================================
# Checking Configuration
# ==============================================================================