Skip to content

Instantly share code, notes, and snippets.

@deepakjois
Created December 13, 2011 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakjois/1470500 to your computer and use it in GitHub Desktop.
Save deepakjois/1470500 to your computer and use it in GitHub Desktop.
Helper script to create a template for HTML5Please
#!/bin/bash
promptValue() {
read -p "$1"": " val
echo $val
}
feature=
status=
tags=
while [ -z "$feature" ]
do
feature=$(promptValue "Enter Feature Name")
done
while [ -z "$status" ]
do
status=$(promptValue "Enter Status (use,avoid or caution)")
case $status in
use|avoid|caution) : ;;
*) status= ;;
esac
done
while [ -z "$tags" ]
do
tags=$(promptValue "Enter Tags (one or more of: gtie6 gtie7 gtie8 nopolyfill polyfill fallback)")
if [ -n "$tags" ]
then
set $(echo $tags)
while [ $# -gt 0 ]
do
case "$1" in
gtie6|gtie7|gtie8|nopolyfill|pollyfill|fallback) shift ;;
*) echo "Unknown Tag: $1" 1>&2; tags= ; break ;;
esac
done
fi
done
POSTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/posts"
[ -e "$POSTS_DIR/$feature.md" ] && echo "$feature.md already exists" && exit 1
cat > $POSTS_DIR/$feature.md <<EOF
feature: $feature
status: $status
tags: $tags
polyfillurls:
Replace me!
EOF
echo "Created file $POSTS_DIR/$feature.md" 1>&2
[ -n "$EDITOR" ] && $EDITOR "$POSTS_DIR/$feature.md"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment