summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-12-14 10:48:57 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2017-12-14 10:48:57 +0100
commite0b52f489260c6915ab74c2ebdb5668d1eabd334 (patch)
tree155d77a6e77401711cb7ed7e1a57a0928ece90db
parent85ae5dd4e7c57e80a82622760244dfc81404a34e (diff)
gendocs.sh: Fix tabulations
Change-Id: If9b06695c874f861859793b621264121d2152f11 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rwxr-xr-xgendocs.sh34
1 files changed, 18 insertions, 16 deletions
diff --git a/gendocs.sh b/gendocs.sh
index 4657607..f84e116 100755
--- a/gendocs.sh
+++ b/gendocs.sh
@@ -9,7 +9,7 @@ VERSION=$(grep '"version":' $(dirname $BASH_SOURCE)/book.json | cut -d'"' -f 4)
function usage() {
- cat <<EOF >&2
+ cat <<EOF >&2
Usage: $SCRIPT [options] [pdf|serve|doxygen]
Options:
@@ -21,14 +21,19 @@ Options:
get this help
Example:
- $SCRIPT pdf
+ $SCRIPT pdf
EOF
- exit 1
+ exit ${1:-1}
}
function info() {
- echo "$@" >&2
+ echo "$@" >&2
+}
+
+function error() {
+ info "error:" "$@"
+ exit 1
}
#default values
@@ -39,13 +44,13 @@ OUT_DIR=./build
[[ $? != 0 ]] && usage
while [ $# -gt 0 ]; do
- case "$1" in
- --debug) DEBUG_FLAG="--log=debug --debug";;
- -d|--dry) DRY=echo;;
- -h|--help) usage;;
+ case "$1" in
+ --debug) DEBUG_FLAG="--log=debug --debug";;
+ -d|--dry) DRY=echo;;
+ -h|--help) usage 0;;
pdf | serve | doxygen) DO_ACTION=$1;;
- --) break;;
- esac
+ --) break;;
+ esac
shift
done
@@ -56,18 +61,15 @@ ROOTDIR=`pwd -P`
[ -d $OUT_DIR ] || mkdir -p $OUT_DIR
if [ "$DO_ACTION" = "pdf" -o "$DO_ACTION" = "serve" ]; then
- GITBOOK=`which gitbook`
- [ "$?" = "1" ] && { echo "You must install gitbook first, using: sudo npm install -g gitbook-cli"; exit 1; }
-
- EBCONV=`which ebook-convert`
- [ "$?" = "1" ] && { echo "You must install calibre first, using: 'sudo apt install calibre' or refer to https://calibre-ebook.com/download"; exit 1; }
+ GITBOOK=`which gitbook` || error "You must install gitbook first, using: sudo npm install -g gitbook-cli"
+ EBCONV=`which ebook-convert` || error "You must install calibre first, using: 'sudo apt install calibre' or refer to https://calibre-ebook.com/download"
if [ "$DO_ACTION" = "pdf" ]; then
# Update cover when book.json has been changed
[[ $ROOTDIR/book.json -nt $ROOTDIR/docs/cover.jpg ]] && { echo "Update cover files"; $ROOTDIR/docs/resources/make_cover.sh || exit 1; }
- OUTFILE=$OUT_DIR/$OUTFILENAME.pdf
+ OUTFILE=$OUT_DIR/$OUTFILENAME.pdf
$DRY $GITBOOK pdf $ROOTDIR $OUTFILE $DEBUG_FLAG
[ "$?" = "0" ] && echo "PDF has been successfully generated in $OUTFILE"
else