blog/utils/main.sh

48 lines
1.0 KiB
Bash
Raw Normal View History

2023-09-03 01:22:34 +00:00
#!/usr/bin/bash
PROJ_DIR=~/Blog
CONFIG=$PROJ_DIR/utils/config.sh
## Loading in config
[[ -f $CONFIG ]] && . $CONFIG
include generate
usage () {
cat <<EOF
2023-09-06 02:43:02 +00:00
main.sh [ -n | --new "<title>" "<filename>" ] [ -r | --regenerate ]
2023-09-06 02:44:29 +00:00
Legend:
-n | --new Create new blog post/wiki with provided information
-r | --regenerate Regenerate your index.wiki file
2023-09-03 01:22:34 +00:00
EOF
}
while [[ $# -ne 0 ]]; do
case $1 in
-n | --new)
shift
: "
$1 = Title
$2 = Filename
"
2023-10-31 03:37:18 +00:00
DATESTAMP=`date +%s`
2023-09-03 01:22:34 +00:00
TITLE="${1:?"main.sh : Title was not provided"}"
FILENAME="${2:?"main.sh : Filename was not provided"}"
2023-10-31 03:37:18 +00:00
generate_blog_post "$TITLE" "$DATESTAMP-$FILENAME"
2023-09-03 01:22:34 +00:00
sync
generate_index
break
;;
-r | --regenrate )
## This will regnerate index
generate_index
exit 0
;;
*)
usage
exit 1
;;
2023-09-03 01:22:34 +00:00
esac
done