Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 83 lines (67 sloc) 1.702 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#!/bin/bash

# Function Abstracting Prompts

promptValue() {
 read -p "$1"": " val
 echo $val
}

feature=
status=
tags=
kind=

while [ -z "$feature" ]
do
feature=$(promptValue "Enter Feature Name")
done

# Make feature name slug friendly
feature=$(
  echo $feature |
  # Use sed to replace spaces with hyphens
  sed -e "s/ /-/" |
  # BSD sed doesn't accept \L, so use tr instead for case conversion
  tr "[A-Z]" "[a-z]"
)

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,prefixes,polyfill, fallback, or none)")
    if [ -n "$tags" ]
    then
set $(echo $tags)
      while [ $# -gt 0 ]
      do
case "$1" in
            gtie6|gtie7|gtie8|prefixes|polyfill|fallback|none) shift ;;
            *) echo "Unknown Tag: $1" 1>&2; tags= ; break ;;
          esac
done
fi
done

while [ -z "$kind" ]
do
kind=$(promptValue "Enter Type (css,html,js,api or svg)")
    case $kind in
        css|html|js|api|svg) : ;;
        *) kind= ;;
    esac
done


# Creating markdown file in posts folder
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
kind: $kind
polyfillurls:

EOF

echo "Created file $POSTS_DIR/$feature.md" 1>&2

# Open it in your editor for adding content
[ -n "$EDITOR" ] && $EDITOR "$POSTS_DIR/$feature.md"
Something went wrong with that request. Please try again.