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
|
|
|
|
;;
|
2023-09-06 02:39:39 +00:00
|
|
|
|
|
|
|
-r | --regenrate )
|
2023-11-07 18:30:04 +00:00
|
|
|
## This will run all generate scripts/functions in the generate_hook function
|
|
|
|
generate_hook
|
2023-09-06 02:39:39 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
2023-09-06 02:11:06 +00:00
|
|
|
*)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
2023-09-03 01:22:34 +00:00
|
|
|
esac
|
|
|
|
done
|