File tree Expand file tree Collapse file tree 5 files changed +66
-121
lines changed
Expand file tree Collapse file tree 5 files changed +66
-121
lines changed Original file line number Diff line number Diff line change @@ -5,33 +5,8 @@ set -o errexit
55# Source shared utilities
66source " $( dirname " $0 " ) /get_paths.sh"
77
8- POSITIONAL_ARGS=()
9-
10- while [[ $# -gt 0 ]]; do
11- case $1 in
12- --stackDirs)
13- stackDirs=$2
14- shift # past argument
15- shift
16- ;;
17- --stacksPath)
18- stacksPath=$2
19- shift # past argument
20- shift
21- ;;
22- -* |--* )
23- echo " Unknown option $1 "
24- exit 1
25- ;;
26- * )
27- POSITIONAL_ARGS+=(" $1 " ) # save positional arg
28- shift # past argument
29- ;;
30- esac
31- done
32-
33- # Restore positional parameters
34- restore_positional_args POSITIONAL_ARGS
8+ # Parse all arguments
9+ parse_arguments " $@ "
3510
3611# Set defaults for stack arguments
3712set_stack_defaults
Original file line number Diff line number Diff line change 55# Source shared utilities
66source " $( dirname " $0 " ) /get_paths.sh"
77
8- POSITIONAL_ARGS=()
9- VERBOSE=" false"
10-
11- while [[ $# -gt 0 ]]; do
12- case $1 in
13- --stackDirs)
14- stackDirs=$2
15- shift # past argument
16- shift
17- ;;
18- --stacksPath)
19- stacksPath=$2
20- shift # past argument
21- shift
22- ;;
23- -* |--* )
24- echo " Unknown option $1 "
25- exit 1
26- ;;
27- * )
28- POSITIONAL_ARGS+=(" $1 " ) # save positional arg
29- shift # past argument
30- ;;
31- esac
32- done
33-
34- # Restore positional parameters
35- restore_positional_args POSITIONAL_ARGS
8+ # Parse all arguments
9+ parse_arguments " $@ "
3610
3711# Set defaults for stack arguments
3812set_stack_defaults
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3- # Shared utilities for devfile registry test scripts
4- # Usage: source this file and call set_stack_defaults() after parsing arguments
5-
63# Common variables used by all scripts
74stackDirs=' '
85stacksPath=' '
6+ POSITIONAL_ARGS=()
7+
8+ # Function to parse all arguments
9+ parse_arguments () {
10+ while [[ $# -gt 0 ]]; do
11+ case $1 in
12+ --stackDirs)
13+ stackDirs=$2
14+ shift # past argument
15+ shift
16+ ;;
17+ --stacksPath)
18+ stacksPath=$2
19+ shift # past argument
20+ shift
21+ ;;
22+ -* |--* )
23+ # Try script-specific handler if it exists
24+ local consumed=0
25+ if declare -f handle_additional_args > /dev/null 2>&1 ; then
26+ handle_additional_args " $@ "
27+ consumed=$?
28+ fi
29+
30+ if [ $consumed -gt 0 ]; then
31+ # Script handler consumed some arguments
32+ for (( i= 0 ; i< consumed; i++ )) ; do
33+ shift
34+ done
35+ else
36+ echo " Unknown option $1 "
37+ exit 1
38+ fi
39+ ;;
40+ * )
41+ POSITIONAL_ARGS+=(" $1 " ) # save positional arg
42+ shift # past argument
43+ ;;
44+ esac
45+ done
46+
47+ # Restore positional parameters
48+ restore_positional_args POSITIONAL_ARGS
49+ }
950
1051# Function to set default values for stack arguments
1152set_stack_defaults () {
Original file line number Diff line number Diff line change 33# Source shared utilities
44source " $( dirname " $0 " ) /get_paths.sh"
55
6- POSITIONAL_ARGS=()
76SAMPLES=" false"
87VERBOSE=" false"
98
10- while [[ $# -gt 0 ]]; do
11- case $1 in
12- -s|--samples)
13- SAMPLES=" true"
14- shift # past argument
15- ;;
16- -v|--verbose)
17- VERBOSE=" true"
18- shift # past argument
19- ;;
20- --stackDirs)
21- stackDirs=$2
22- shift # past argument
23- shift
24- ;;
25- --stacksPath)
26- stacksPath=$2
27- shift # past argument
28- shift
29- ;;
30- -* |--* )
31- echo " Unknown option $1 "
32- exit 1
33- ;;
34- * )
35- POSITIONAL_ARGS+=(" $1 " ) # save positional arg
36- shift # past argument
37- ;;
38- esac
39- done
40-
41- # Restore positional parameters
42- restore_positional_args POSITIONAL_ARGS
9+ handle_additional_args () {
10+ case $1 in
11+ -s|--samples)
12+ SAMPLES=" true"
13+ return 1
14+ ;;
15+ -v|--verbose)
16+ VERBOSE=" true"
17+ return 1
18+ ;;
19+ * )
20+ return 0
21+ ;;
22+ esac
23+ }
24+
25+ # Parse all arguments
26+ parse_arguments " $@ "
4327
4428set -x
4529
You can’t perform that action at this time.
0 commit comments