case "$arg" in
"--quiet") set -- "$@" "-q" ;;
"--verbose") set -- "$@" "-v" ;;
+ "--working-directory") set -- "$@" "-w" ;;
*) set -- "$@" "$arg" ;;
esac
done
# parse short options
OPTIND=1
- while getopts "qv" opt
+ while getopts "qvw:" opt
do
case "$opt" in
"q") set_loglevel "error" ;;
"v") set_loglevel "info" ;;
+ "w") set_working_directory "$OPTARG" ;;
"?") usage ;;
esac
done
esac
}
+set_working_directory() {
+ log_info "changing working directory to $1"
+ cd "$1"
+}
+
usage() {
log_err "Usage:"
log_err ""
log_err "Options:"
log_err "\t--quiet, -q"
log_err "\t--verbose, -v"
+ log_err "\t--working-directory, -w <directory>"
exit 1
}
clone_repos
fetch_repos
+ set_working_directory "$PWD"
+
log "Successfully updated repos"
exit