@@ -26,7 +26,6 @@ echo -e "${BLUE} Docker Compose One-Click Deployment ${NC}"
2626echo -e " ${BLUE} =================================================${NC} "
2727
2828# 1. Select Deployment Example
29- echo -e " ${GREEN} Select a deployment scenario:${NC} "
3029# List directories in examples/ excluding 'docker'
3130if [ -d " examples" ]; then
3231 OPTIONS=($( ls -d examples/* / | grep -v " examples/docker/" | xargs -n 1 basename) )
@@ -40,16 +39,52 @@ if [ ${#OPTIONS[@]} -eq 0 ]; then
4039 exit 1
4140fi
4241
43- PS3=" Enter choice number: "
44- select OPT in " ${OPTIONS[@]} " ; do
45- if [ -n " $OPT " ]; then
46- SELECTED_EXAMPLE=" $OPT "
47- break
48- else
49- echo " Invalid selection."
50- fi
42+ # Parse arguments manually since we are inside the script flow
43+ ARG_PROJECT=" "
44+
45+ while [[ $# -gt 0 ]]; do
46+ key=" $1 "
47+ case $key in
48+ -p|--project)
49+ ARG_PROJECT=" $2 "
50+ shift # past argument
51+ shift # past value
52+ ;;
53+ * )
54+ echo -e " ${RED} Unknown option: $1 ${NC} "
55+ echo -e " Usage: ./setup-services.sh [-p|--project <name>]"
56+ exit 1
57+ ;;
58+ esac
5159done
5260
61+ # Logic to select example
62+ if [ -n " $ARG_PROJECT " ]; then
63+ for opt in " ${OPTIONS[@]} " ; do
64+ if [ " $opt " == " $ARG_PROJECT " ]; then
65+ SELECTED_EXAMPLE=" $opt "
66+ echo -e " ${GREEN} Project selected via argument: $SELECTED_EXAMPLE ${NC} "
67+ break
68+ fi
69+ done
70+ if [ -z " $SELECTED_EXAMPLE " ]; then
71+ echo -e " ${RED} Invalid project: $ARG_PROJECT ${NC} "
72+ echo -e " Available options: ${OPTIONS[*]} "
73+ exit 1
74+ fi
75+ else
76+ echo -e " ${GREEN} Select a deployment project:${NC} "
77+ PS3=" Enter choice number: "
78+ select OPT in " ${OPTIONS[@]} " ; do
79+ if [ -n " $OPT " ]; then
80+ SELECTED_EXAMPLE=" $OPT "
81+ break
82+ else
83+ echo " Invalid selection."
84+ fi
85+ done
86+ fi
87+
5388echo -e " ${GREEN} Selected: $SELECTED_EXAMPLE ${NC} "
5489
5590# 2. Prepare Target Directory
0 commit comments