blob: 79b2f53ea690f0a5015d6ec38a12dfddef77aa98 (
plain) (
tree)
|
|
#!/bin/sh
set -eu
usage() {
cat <<-'EOF'
Usage:
coll2path LANGUAGE COLLECTION
coll2path -h
EOF
}
help() {
cat <<-'EOF'
Options:
-h, --help show this message
LANGUAGE in which language to list the collections
names for
COLLECTION what collection to get the path for
Get the path for the COLLECTION, doing the proper translation
on the way, and checking if is "article".
Examples:
Get the path for "TIL" in portuguese:
$ coll2path pt til
hea/
Get the path for "articles" in english
$ collections en articles
EOF
}
for flag in "$@"; do
case "$flag" in
--)
break
;;
--help)
usage
help
exit
;;
*)
;;
esac
done
while getopts 'h' flag; do
case "$flag" in
h)
usage
help
exit
;;
*)
usage >&2
exit 2
esac
done
shift $((OPTIND - 1))
. src/lib.sh
LANGUAGE="${1:-}"
COLLECTION="${2:-}"
eval "$(assert_arg "$LANGUAGE" 'LANGUAGE')"
# shellcheck source=/dev/null
. src/lib/commencement."$LANGUAGE".conf
if [ -z "$COLLECTION" ]; then
echo "${article_collection_name:-}"
else
NAME="$(eval "echo \"\$${COLLECTION}_collection_name\"")"
echo "$NAME${NAME:+/}"
fi
|