Skip to content

Commit 5f5b511

Browse files
committed
cqfd: smoothen up user interface
The user interface is refactored to rely on explicit action verbs such as "run", "release" or "init" instead of short options. Documentation is updated accordingly. Change-Id: I69bc72525cc13b1644200a5610ed161f6d768644
1 parent 823c14e commit 5f5b511

File tree

3 files changed

+43
-49
lines changed

3 files changed

+43
-49
lines changed

CHANGELOG

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
== Untagged changes
44

5+
* Use action verbs in user interface
56
* Do not have user depend on SSH_AUTH_SOCK
67

78
== Version v1

common/sfl/README.cqfd

+7-6
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ The following command creates the initial build container after
7676
entering your project's git repository:
7777

7878
$ cd path/to/fooinc/buildroot/
79-
$ sfl/cqfd -i
79+
$ sfl/cqfd init
8080

8181
+cqfd+ will use the provided Dockerfile to create a normalized runtime
8282
build environment for your project.
@@ -94,15 +94,16 @@ Alternatively, you may want to specify a custom build command to be
9494
executed from inside the build container. To do this, use the -b
9595
option:
9696

97-
$ sfl/cqfd -b "make clean"
97+
$ sfl/cqfd run make clean
98+
$ sfl/cqfd run "make linux-dirclean && make foobar-dirclean"
9899

99100
==== Release
100101

101-
The +-j+ option allows creating a release tarball for your
102-
project. The release files (as specified in your +.sflproject+) will
103-
be included inside the release archive.
102+
The release command behaves exactly like run, but creates a release
103+
tarball for your project additionally. The release files (as specified
104+
in your +.sflproject+) will be included inside the release archive.
104105

105-
$ sfl/cqfd -j
106+
$ sfl/cqfd release
106107

107108
The resulting release file is then called
108109
${JOB_NAME}_${BUILD_ID}.tar.xz, where JOB_NAME is either your Jenkins

common/sfl/cqfd

+35-43
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,19 @@ ESUCCESS=0
1111
PROGNAME=`basename $0`
1212
TOPDIR=`cd $(dirname $0)/..; pwd`
1313

14-
## usage() - print usage on stdin
14+
## usage() - print usage on stdout
1515
usage() {
1616
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.
3227
EOF
3328
}
3429

@@ -141,33 +136,30 @@ if [ -n "$CUST_CODENAME" -a -n "$CUST_PROJECT" ]; then
141136
DOCKER_IMG_NAME="${CUST_CODENAME}_${CUST_PROJECT}"
142137
fi
143138

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
171163

172164
if [ -z "$BUILD_CMD" ]; then
173165
die "No build.command defined in .sflproject !"

0 commit comments

Comments
 (0)