diff --git a/fejctl b/fejctl index d55e090..7ee69df 100755 --- a/fejctl +++ b/fejctl @@ -8,7 +8,10 @@ image='chewingbever/fej' # -b: build the builder # -r: use the release image instead function dc() { + local OPTIND c build_builder release + while getopts ":br" c; do + echo "$c" case $c in b ) build_builder=1 ;; r ) release=1 ;; @@ -52,7 +55,7 @@ function dcr() { # Tags & pushes the release version to Docker Hub function publish() { - branch=`git rev-parse --abbrev-ref HEAD` + local branch=`git rev-parse --abbrev-ref HEAD` if [[ "$branch" != master ]]; then >&2 echo "You can only publish from master." @@ -62,10 +65,10 @@ function publish() { # Build the release images dc -br build - patch_version=`grep -Po '(?<=version = ").*(?=")' Cargo.toml | head -n1` - major_version=`echo "$patch_version" | sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/'` - minor_version=`echo "$patch_version" | sed -E 's/([0-9]+).([0-9]+).([0-9]+)/\1.\2/'` - tags=("latest" "$patch_version" "$minor_version" "$major_version") + local patch_version=`grep -Po '(?<=version = ").*(?=")' Cargo.toml | head -n1` + local major_version=`echo "$patch_version" | sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/'` + local minor_version=`echo "$patch_version" | sed -E 's/([0-9]+).([0-9]+).([0-9]+)/\1.\2/'` + local tags=("latest" "$patch_version" "$minor_version" "$major_version") for tag in "${tags[@]}"; do # Create the tag @@ -86,8 +89,8 @@ function publish() { # $2: binary to use, defaults to 'server' function main() { # Default values - cmd="${1:-build}" - bin="${2:-server}" + local cmd="${1:-build}" + local bin="${2:-server}" case $cmd in # Building