M README.md => README.md +15 -2
@@ 6,7 6,7 @@ EPUB-CREATE(1) - General Commands Manual
# SYNOPSIS
-**epub-create** \[**-o** cover] *dir*
+**epub-create** \[**-i**] \[**-o** cover] *dir*
# DESCRIPTION
@@ 14,7 14,7 @@ EPUB-CREATE(1) - General Commands Manual
is a simple POSIX shell script for creating an EPUB document from a
directory containing non-binary files.
-When run,
+When run on a directory for the first time,
**epub-create**
will ask for the document title, authors, language and publication ID.
Pressing ENTER at any prompt will result in a default value being
@@ 25,6 25,13 @@ used; the defaults are
and
"\[unknown]",
respectively.
+
+The values are then saved in
+*dir*/.conf,
+which will provide their values for future runs, unless the
+**-i**
+option is specified.
+
**epub-create**
will then start
`EDITOR`
@@ 63,6 70,12 @@ zip(1).
# OPTIONS
+**-i**
+
+> Interactive: ask user for title, author, etc. even if already
+> specified in
+> *dir*/.conf.
+
**-o** cover
> Generate a cover page with document title and author(s).
M epub-create => epub-create +34 -14
@@ 17,11 17,14 @@ then
exit 1
fi
-USAGE='Usage: epub-create [-o cover] dir'
+USAGE='Usage: epub-create [-i] [-o cover] dir'
-while getopts o: OPT
+while getopts io: OPT
do
case "${OPT}" in
+ i)
+ INTERACTIVE=yes
+ ;;
o)
if [ -z "${OPTARG}" ]
then
@@ 102,19 105,36 @@ FIN
}
+if [ -f "${DIR}/.conf" ] && [ ! "${INTERACTIVE}" ]
+then
+ . "${DIR}/.conf"
+else
-printf %s 'Title? '
-read -r TITLE
-: "${TITLE:='A Document'}"
-printf %s 'Authors? '
-read -r AUTHORS
-: "${AUTHORS:='[unknown]'}"
-printf %s 'Language? '
-read -r DOC_LANG
-: "${DOC_LANG:='en'}"
-printf %s 'Publication ID? '
-read -r PUB_ID
-: "${PUB_ID:='[unknown]'}"
+ printf %s 'Title? '
+ read -r TITLE
+ : "${TITLE:='A Document'}"
+ printf %s 'Authors? '
+ read -r AUTHORS
+ : "${AUTHORS:='[unknown]'}"
+ printf %s 'Language? '
+ read -r DOC_LANG
+ : "${DOC_LANG:='en'}"
+ printf %s 'Publication ID? '
+ read -r PUB_ID
+ : "${PUB_ID:='[unknown]'}"
+
+ if [ -f "${DIR}/.conf" ]
+ then
+ rm -f "${DIR}/.conf"
+ fi
+ cat >> "${DIR}/.conf" << FIN
+TITLE="${TITLE}"
+AUTHORS="${AUTHORS}"
+DOC_LANG="${DOC_LANG}"
+PUB_ID="${PUB_ID}"
+FIN
+
+fi
FILES=$(ls -1 "${DIR}")
TMP_DIR="$(mktemp -d)"
M epub-create.1 => epub-create.1 +13 -1
@@ 6,6 6,7 @@
.Nd simple shell script for creating EPUB documents
.Sh SYNOPSIS
.Nm
+.Op Fl i
.Op Fl o No cover
.Ar dir
.Sh DESCRIPTION
@@ 13,7 14,7 @@
is a simple POSIX shell script for creating an EPUB document from a
directory containing non-binary files.
.Pp
-When run,
+When run on a directory for the first time,
.Nm
will ask for the document title, authors, language and publication ID.
Pressing ENTER at any prompt will result in a default value being
@@ 24,6 25,13 @@ used; the defaults are
and
.Dq [unknown] ,
respectively.
+.Pp
+The values are then saved in
+.Ar dir Ns / Ns .conf ,
+which will provide their values for future runs, unless the
+.Fl i
+option is specified.
+.Pp
.Nm
will then start
.Ev EDITOR
@@ 61,6 69,10 @@ and
.Xr zip 1 .
.Sh OPTIONS
.Bl -tag -width x
+.It Fl i
+Interactive: ask user for title, author, etc. even if already
+specified in
+.Ar dir Ns / Ns .conf .
.It Fl o No cover
Generate a cover page with document title and author(s).
.El