From b6cfc4804e9e71ee64d288d615d0904d55509f58 Mon Sep 17 00:00:00 2001
From: Dmytro Bogatov <dmytro@dbogatov.org>
Date: Thu, 9 Nov 2017 22:39:57 -0500
Subject: [PATCH] Add CLI.

---
 .gitlab-ci.yml |  1 +
 build.sh       | 17 ++++++++++++++---
 cli.tex        | 20 ++++++++++++++++++++
 main.tex       |  9 +++++----
 preamble.tex   |  4 +++-
 5 files changed, 43 insertions(+), 8 deletions(-)
 create mode 100644 cli.tex

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a54a14f..61794d8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -28,6 +28,7 @@ artifacts:
   - ./install-font-debian.sh
   - printf "\providecommand{\\\version}{%s}" $(echo $CI_BUILD_REF | cut -c1-8) > version.tex
   - ./build.sh
+  - ./build.sh -n -c presentation-with-notes
   - mv dist/*.pdf .
   artifacts:
     paths:
diff --git a/build.sh b/build.sh
index 270fed7..756572f 100755
--- a/build.sh
+++ b/build.sh
@@ -8,8 +8,9 @@ OUTDIR=dist
 JOBNAME=presentation
 ITERATIONS=3
 LATEX_DEBUG=""
+LATEX_NOTES=""
 
-usage() { echo "Usage: $0 [-i <number> -g -v -t]" 1>&2; exit 1; }
+usage() { echo "Usage: $0 [-i <number> -g -v -t -n -c <string>]" 1>&2; exit 1; }
 
 log() {
 	if [ -n "${VERBOSE}" ]; then 
@@ -40,7 +41,7 @@ test() {
 	echo "Tests passed!"
 }
 
-while getopts "i:vgt" o; do
+while getopts "c:i:vgtn" o; do
 	case "${o}" in
 		g)
 			DEBUG=true
@@ -49,6 +50,12 @@ while getopts "i:vgt" o; do
 		v)
 			VERBOSE=true
 			;;
+		c)
+			JOBNAME=${OPTARG}
+			;;
+		n)
+			NOTES=true
+			;;
 		i)
 			ITERATIONS=${OPTARG}
 			;;
@@ -76,6 +83,10 @@ if [ -n "${DEBUG}" ]; then
 	LATEX_DEBUG="\def\debug{true}"
 fi
 
+if [ -n "${NOTES}" ]; then
+	LATEX_NOTES="\def\generatenotes{true}"
+fi
+
 echo "Compiling the project into ${JOBNAME}.pdf ..."
 
 for j in `seq 1 $ITERATIONS`;	
@@ -84,7 +95,7 @@ do
 		--interaction=${INTERACTION} \
 		-output-directory=${OUTDIR} \
 		-jobname=${JOBNAME} \
-		main
+		"${LATEX_NOTES}${LATEX_DEBUG}\input main.tex"
 
 	if [ "$j" == "1" ]
 	then
diff --git a/cli.tex b/cli.tex
new file mode 100644
index 0000000..ac492ae
--- /dev/null
+++ b/cli.tex
@@ -0,0 +1,20 @@
+% cSpell:disable
+
+% CLI arguments
+
+\newif\ifrelease%
+
+\ifdefined\debug%
+	\releasefalse%
+\else
+	\releasetrue%
+\fi
+
+
+\newif\ifnotes%
+
+\ifdefined\generatenotes%
+	\notestrue%
+\else
+	\notesfalse%
+\fi
diff --git a/main.tex b/main.tex
index 0d16ef8..99560d7 100644
--- a/main.tex
+++ b/main.tex
@@ -1,11 +1,12 @@
 % cSpell:ignore bibfile
 
 \documentclass{beamer}
+	
+	\input{cli}
+	\input{version}
 
-\input{version}
-
-\input{packages}
-\input{preamble}
+	\input{packages}
+	\input{preamble}
 
 \begin{document}
 
diff --git a/preamble.tex b/preamble.tex
index dc61760..3df6bd4 100644
--- a/preamble.tex
+++ b/preamble.tex
@@ -5,7 +5,9 @@
 	titleformat section=smallcaps
 ]{metropolis}
 
-\setbeameroption{show notes on second screen}
+\ifnotes%
+	\setbeameroption{show notes on second screen}
+\fi
 
 \title{Data-X Talk} % chktex 13
 
-- 
GitLab