aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2021-12-31 09:20:06 -0500
committerPaul Duncan <pabs@pablotron.org>2021-12-31 09:20:06 -0500
commit7c3b8380228cbd1ad7d0285807e98e4768740a30 (patch)
treec2f8fa091a19c7f184cfea6ac3483b0d2800177f
parentc2fa270d4bab246b26b40ed3952fe9a921fdc302 (diff)
downloadpablotron.org-7c3b8380228cbd1ad7d0285807e98e4768740a30.tar.bz2
pablotron.org-7c3b8380228cbd1ad7d0285807e98e4768740a30.zip
bin/new: improve header comment, add "help" option, disable "project" type
-rwxr-xr-xbin/new21
1 files changed, 17 insertions, 4 deletions
diff --git a/bin/new b/bin/new
index e6d176c..c64d0d5 100755
--- a/bin/new
+++ b/bin/new
@@ -1,7 +1,10 @@
#!/bin/bash
#
-# generate new content
+# Generate new content.
+#
+# Usage:
+# bin/new [post|article] SLUG
#
# Examples:
# # create new post with slug "great-news" and title "Great News"
@@ -10,17 +13,27 @@
# # create new article with slug "some-stuff" and title "Some Stuff"
# bin/new article some-stuff
#
-# # create new project with slug "cool-app" and title "Cool App"
-# bin/new project cool-app
+# # print help
+# bin/new help
#
+# set sane error handling
+set -eu
+
+# switch on type
if [ "$1" = 'post' ]; then
DATE=$(date +%Y-%m-%d)
exec hugo new --editor $EDITOR posts/"$DATE"-"$2".md
elif [ "$1" = 'project' ]; then
- exec hugo new --editor $EDITOR projects/"$2".md
+ # disabled, use projects.yaml instead
+ # exec hugo new --editor $EDITOR projects/"$2".md
+ echo "Error: Populate data/projects.yaml instead."
elif [ "$1" = 'article' ]; then
+ # create article
exec hugo new --editor $EDITOR articles/"$2".md
+elif [ "$1" = 'help' -o "x$1" = 'x' ]; then
+ # print usage
+ echo "Usage: $0 [post|article]"
else
echo "unknown type: $1"
fi