I want to do a argument parser inside one argument.
Here is my launcher ./bin/kube/launch_market_quality_job.sh -e staging -j job_example
And here my script.
while [ ${#} -ne 0 ]; do
case "${1}" in
--environment | -e)
shift;
export ONE_ENVIRON=${1};
case $ONE_ENVIRON in
staging)
export REPOSITORY=<DTR>
;;
production)
export REPOSITORY=<DTR>
;;
*)
fail "You must provide the environment [staging|production]"
;;
esac
;;
--job | -j )
shift;
export JOB=${1}
case $JOB in
job_example_extra_args)
case "${1}" in
--name | -n )
export $NAME=${1}
[... extra args]
;;
*)
help
exit
;;
esac
shift
done
What I want to do is depending on "--j | -job" option, is to parse two more options depending if the jobs if one or another.
For example a normal job , called 'job_example' with the previous launcher it works correctly.
But if my job is 'job_example_extra_args' I need a new argument called 'name'.
`./bin/kube/launch_market_quality_job.sh -e staging -j job_example_extra_args --name "Jesus"`
I dont know how is the correct way, if this 'job_example_extra_args' is called, I want to obtain the flag correctly, and if its not included the script should fail or stop. I want to add the flags options inside the --job flag, for activating it if the job is the one I want to.