added short options

pull/1/head
Daniel Mikula 2023-05-15 11:26:38 +02:00
parent dc16660e00
commit 8f3e5f14c7
1 changed files with 50 additions and 16 deletions

View File

@ -3,41 +3,75 @@
# Author : NTT Data AG
# Date : 11-05-2023
show_help() {
echo "Usage: $0 [-m <boolean>] [-a <app_name>]"
echo "Options:"
echo " -m <boolean> Install helm"
echo " -a <app_name> Specify the app name"
}
helm_install=false
app_name=""
while getopts "hm:a:" option; do
case $option in
h)
# fetch helm resources
# docs: https://helm.sh/docs/intro/install/
install_helm () {
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
}
show_help() {
cat <<EOF
Usage: $0 [options]
Options:
-h, --help Show help information
-m, --helm Install Helm
-a, --app <app_name> Specify the app name
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
-h|--help)
show_help
exit 0
;;
m)
helm_install="$OPTARG"
-m|--helm)
helm_install=true
shift
;;
a)
app_name="$OPTARG"
-a|--app)
if [ "$2" ]; then
app_name="$2"
shift 2
else
echo "Error: Missing argument for $1 option"
show_help
exit 1
fi
;;
*)
echo "Error: Unrecognized option $1"
show_help
exit 1
;;
esac
done
if [ "$helm_install" = "true" ]; then
# Check if --helm was set
if [ "$helm_install" = true ]; then
echo "Installing helm"
# install_helm
else
echo "Skipping helm"
fi
# Validate app names
if [ -z "$app_name" ]; then
echo "Please specify app"
else
echo "Installing $app_name"
case $app_name in
"socks_shop")
echo "installing sock shop"
;;
*)
echo "Only following apps allowed"
exit 1
;;
esac
fi