#!/bin/zsh baseDir=${0:a:h} export baseDir set -e # Parse command line arguments if [[ $# -eq 0 ]]; then echo "Usage: $0 [ ]" exit 1 fi operation=$1 echo arg num: $# echo "args: $0 $1 $2" source_code_dir=/home/yu/work/boot # Determine which operation to perform set -x case $operation in "unpack") cd ${source_code_dir} pwd if [[ $# -eq 2 ]]; then file=`realpath $2` dir=`realpath out` gradle unpack --args="unpackInternal $file $dir" elif [[ $# -eq 3 ]]; then file=`realpath $2` dir=`realpath $3` cd ${baseDir}/../../../ gradle unpack --args="unpackInternal $file $dir" else cd ${baseDir}/../../../ gradle unpack fi ;; "pack") pwd if [[ $# -eq 3 ]]; then dir=`realpath $2` file=`realpath $3` #cd ${baseDir}/../../../ cd ${source_code_dir} gradle pack --args="packInternal $dir $file" else #cd ${baseDir}/../../../ cd ${source_code_dir} gradle pack fi ;; *) echo "Invalid operation: $operation. Please choose 'unpack' or 'pack'." exit 1 ;; esac