Skip to content

Instantly share code, notes, and snippets.

@srathi-monarch
Created June 18, 2024 10:19
Show Gist options
  • Save srathi-monarch/75df6132b18e4c8a605661b80aabc4f0 to your computer and use it in GitHub Desktop.
Save srathi-monarch/75df6132b18e4c8a605661b80aabc4f0 to your computer and use it in GitHub Desktop.
#! /usr/bin/zsh
set -euo pipefail
# Arguments
# -t | --tractor=TRACTOR_NAME
# -r | --run=RUN_NAME
DATA_HOME="${HOME}/kalibr_ws/sync_logs/"
__usage__name=$(basename "${0}")
usage() {
echo "${__usage__name} -t <tractor_name> -r <run_name>"
echo "-t | --tractor=tractor_name The name of the tractor to run on. The entries for {$(echo n1 x{1,2,3,4})}<tractor_name> must exist in ~/.ssh/config"
echo "-r | --run=run_name The subdirectory in ${DATA_HOME} to store the results in. This also affects the topic used to end logging."
}
if ! parsed_args=$(getopt -l 'tractor:,run:,help' -o 't:r:h' -- "$@"); then
echo "Failed to parse arguments"
usage
exit 1
fi
eval set -- "${parsed_args}"
run=""
tractor=""
while [[ $# -gt 0 ]]; do
case $1 in
-t | --tractor)
tractor=$2
shift 2
;;
-r | --run)
run=$2
shift 2
;;
-h | --help)
usage
exit 0
;;
--)
shift
break
;;
*)
echo "Invalid option: $1"
usage
exit 1
;;
esac
done
[[ $# != 0 ]] && {
# Handle positional arguments
echo "Invalid arguments passed, this script does not take any positional arguments."
usage
return 1
}
[[ -z "${run}" ]] && {
echo "Run name not provided."
usage
return 1
}
[[ -z "${tractor}" ]] && {
echo "Tractor name not provided."
usage
return 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment