blog script now takes optional -f FILE_PATTERN arg
This commit is contained in:
+10
-4
@@ -7,7 +7,7 @@ export LAYOUTS="$(realpath share/layouts)"
|
|||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
>&2 cat << USAGE
|
>&2 cat << USAGE
|
||||||
usage: blog -i LOG [-p POSTPROCESS_CMD] [-a EXTRACT_ARGS_CMD] [-l LAYOUT] [-t]
|
usage: blog -i LOG [-p POSTPROCESS_CMD] [-a EXTRACT_ARGS_CMD] [-l LAYOUT] [-t] [-f FILE_PATTERN]
|
||||||
|
|
||||||
options:
|
options:
|
||||||
|
|
||||||
@@ -15,6 +15,9 @@ options:
|
|||||||
If provided, a shell command to extract arguments to the layout from the
|
If provided, a shell command to extract arguments to the layout from the
|
||||||
source files. The shell will be provided with a variable, POST_TITLE.
|
source files. The shell will be provided with a variable, POST_TITLE.
|
||||||
|
|
||||||
|
-f FILE
|
||||||
|
If provided, a pattern for the files to process. Default: *.
|
||||||
|
|
||||||
-i LOG
|
-i LOG
|
||||||
The name of the source directory under \$BLOGS where log posts live.
|
The name of the source directory under \$BLOGS where log posts live.
|
||||||
|
|
||||||
@@ -32,17 +35,21 @@ USAGE
|
|||||||
}
|
}
|
||||||
|
|
||||||
extract_args_cmd="head -n 0 | echo \"POST_TITLE=\\\"\${POST_TITLE}\\\"\""
|
extract_args_cmd="head -n 0 | echo \"POST_TITLE=\\\"\${POST_TITLE}\\\"\""
|
||||||
|
file_pattern="*"
|
||||||
log_name=""
|
log_name=""
|
||||||
layout="default"
|
layout="default"
|
||||||
postprocess_cmd="echo"
|
postprocess_cmd="echo"
|
||||||
use_filenames_for_titles=0
|
use_filenames_for_titles=0
|
||||||
|
|
||||||
while getopts "a:i:l:p:t" opt
|
while getopts "a:f:i:l:p:t" opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
a)
|
a)
|
||||||
extract_args_cmd="$OPTARG"
|
extract_args_cmd="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
f)
|
||||||
|
file_pattern="$OPTARG"
|
||||||
|
;;
|
||||||
i)
|
i)
|
||||||
log_name="$OPTARG"
|
log_name="$OPTARG"
|
||||||
;;
|
;;
|
||||||
@@ -83,10 +90,9 @@ then
|
|||||||
echo >&2 "Warning: no layout found at $(basename "${LAYOUTS}")/${layout_name}.layout.upphtml"
|
echo >&2 "Warning: no layout found at $(basename "${LAYOUTS}")/${layout_name}.layout.upphtml"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "${SRC}/${log_name}/"
|
|
||||||
mkdir -p "${SRC}/${log_name}"
|
mkdir -p "${SRC}/${log_name}"
|
||||||
|
|
||||||
for entry in $(find -L "${BLOGS}/${log_name}" -type f)
|
for entry in $(find -L "${BLOGS}/${log_name}" -type f -name "${file_pattern}")
|
||||||
do
|
do
|
||||||
basename="$(basename "$entry")"
|
basename="$(basename "$entry")"
|
||||||
name="${basename%%\.*}"
|
name="${basename%%\.*}"
|
||||||
|
|||||||
Reference in New Issue
Block a user