@@ -11,24 +11,19 @@ ESUCCESS=0
11
11
PROGNAME=` basename $0 `
12
12
TOPDIR=` cd $( dirname $0 ) /..; pwd`
13
13
14
- # # usage() - print usage on stdin
14
+ # # usage() - print usage on stdout
15
15
usage () {
16
16
cat << EOF
17
- Usage: $PROGNAME [OPTIONS]
18
-
19
- * If you have a .sflproject: $PROGNAME
20
- * If you want to build with a special command: $PROGNAME -b <"CMD">
21
- * If you want default build command: $PROGNAME <OPTIONS>
22
-
23
- Options are:
24
- -b <build command> Specify a build command to pass to
25
- docker.
26
- -g <client_reponame> The name of the docker image
27
- Default is client_reponame,
28
- Note: use before -i
29
- -j Make an archive out of release
30
- files
31
- -i Initialize build container.
17
+ Usage: $PROGNAME [COMMAND] [ARGUMENTS]
18
+
19
+ Commands:
20
+ init Initialize project build container
21
+ run Run argument(s) inside build container
22
+ release Run argument(s) and release software
23
+ help Show this help text
24
+
25
+ By default, run is assumed, and the run command is the one
26
+ configured in .sflproject.
32
27
EOF
33
28
}
34
29
@@ -141,33 +136,30 @@ if [ -n "$CUST_CODENAME" -a -n "$CUST_PROJECT" ]; then
141
136
DOCKER_IMG_NAME=" ${CUST_CODENAME} _${CUST_PROJECT} "
142
137
fi
143
138
144
- while getopts " ijhb:g:" OPTION; do
145
- case " $OPTION " in
146
- h)
147
- usage
148
- exit $ESUCCESS
149
- ;;
150
- b)
151
- BUILD_CMD=" $OPTARG "
152
- ;;
153
- g)
154
- DOCKER_IMG_NAME=" $OPTARG "
155
- ;;
156
- j)
157
- MAKE_ARCHIVE=1
158
- ;;
159
- i)
160
- # We expect a Dockerfile is always present
161
- [ -f " $DOCKER_FILE " ] || die " $DOCKER_FILE not found"
162
- [ -n " $DOCKER_IMG_NAME " ] || die " No customer codename set"
163
- docker_build $DOCKER_IMG_NAME
164
- exit $?
165
- ;;
166
- * )
167
- die " Unknown parameter $OPTION "
168
- ;;
169
- esac
170
- done
139
+ case " $1 " in
140
+ help|-h|--help)
141
+ usage
142
+ exit $ESUCCESS
143
+ ;;
144
+ init)
145
+ # We expect a Dockerfile is always present
146
+ [ -f " $DOCKER_FILE " ] || die " $DOCKER_FILE not found"
147
+ [ -n " $DOCKER_IMG_NAME " ] || die " No customer codename set"
148
+ docker_build $DOCKER_IMG_NAME
149
+ exit $?
150
+ ;;
151
+ run|release)
152
+ [ " $1 " = " release" ] && MAKE_ARCHIVE=1
153
+ shift
154
+ [ $# -ge 1 ] && BUILD_CMD=" $@ "
155
+ ;;
156
+ ?* )
157
+ die " Unknown command: $1 "
158
+ ;;
159
+ * )
160
+ # empty or no argument case
161
+ ;;
162
+ esac
171
163
172
164
if [ -z " $BUILD_CMD " ]; then
173
165
die " No build.command defined in .sflproject !"
0 commit comments