Last active
January 1, 2016 16:29
-
-
Save andreasheil/8171461 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # ChicagoBoss: Erlang for everybody. | |
| # | |
| # | |
| # Shouts: Evan of course, and many other contributors for keeping CB awesome. | |
| # | |
| # | |
| # Copyright 2012 Barry Allard <[email protected]>. All rights reserved. MIT licensed. | |
| # | |
| # Disclaimer: This is an unofficial contrib. | |
| set -e | |
| # ---- config | |
| CHICAGO_VSN=0.8.8 | |
| MY_NAME_IS="$(basename $0)" | |
| HERE="$(dirname $0)" | |
| # ---- functions | |
| err() { | |
| echo "$1" >&1 | |
| } | |
| die() { | |
| err | |
| err "$1" | |
| err | |
| exit ${2:-1} | |
| } | |
| is_atom() { | |
| echo "$1" | egrep -q -- '^([a-z][a-zA-Z0-9_@]*|'\''[^'\''][^'\'']*'\'')$' | |
| } | |
| help() { | |
| die "Usage: $MY_NAME_IS [--head] new_project_name | |
| --head Use ChicagoBoss github master in-development sources instead of the release tarball. | |
| " | |
| } | |
| # ---- start | |
| cd "$HERE" | |
| case "$1" in | |
| --head) | |
| HEAD=1 | |
| shift | |
| ;; | |
| *) | |
| ;; | |
| esac | |
| PROJECT="$1" | |
| if [ -z "$PROJECT" ]; then | |
| help "Missing project name argument" | |
| elif ! is_atom "$PROJECT"; then | |
| die "$MY_NAME_IS: Project name '$PROJECT' must be an atom. | |
| For reference, a valid project atom would be: | |
| [a-z][a-zA-Z0-9_@]* | |
| Dont use the quoted form unless you enjoy pain. | |
| " | |
| fi | |
| if [ -d "$HERE/$PROJECT" ]; then | |
| die "$MY_NAME_IS: $HERE/$PROJECT already exists!" | |
| fi | |
| if [ -n "$HEAD" ]; then | |
| CHICAGO_VSN="HEAD" | |
| DIR="ChicagoBoss-HEAD" | |
| if [ ! -d "$DIR" ]; then | |
| echo Installing ChicagoBoss $CHICAGO_VSN | |
| git clone https://github.com/ChicagoBoss/ChicagoBoss.git "$DIR" | |
| cd "$DIR" | |
| else | |
| echo Updating ChicagoBoss $CHICAGO_VSN | |
| cd "$DIR" | |
| git pull | |
| fi | |
| else | |
| echo Installing ChicagoBoss $CHICAGO_VSN | |
| DIR="ChicagoBoss-$CHICAGO_VSN" | |
| [ ! -d "$DIR" ] && curl -L https://github.com/ChicagoBoss/ChicagoBoss/archive/v$CHICAGO_VSN.tar.gz | tar zxf - | |
| cd "$DIR" | |
| fi | |
| make | |
| make app PROJECT="$PROJECT" | |
| cd "../$PROJECT" | |
| cat > .gitignore << GIT_IGNORE | |
| *.beam | |
| *.app | |
| ebin/ | |
| log/ | |
| GIT_IGNORE | |
| if which git >/dev/null 2>&1; then | |
| git init | |
| git add -A | |
| git commit -m "ChicagoBoss $CHICAGO_VSN bootstrapped a new project: $PROJECT." | |
| fi | |
| cat << "FIST" | |
| ,_, _-, _ | |
| ,--, / |\/' |`\/ |\ | |
| / |` ` ` | | |
| | | | ' | | | |
| | |3 | O | $ | $ | | |
| | | | | |__ | |
| \__/: : | | ) | |
| `---',\___/,-----` / | |
| `--._| / | |
| `------` | |
| FIST | |
| cat << POST | |
| Chicago $CHICAGO_VSN created a new template project $PROJECT. | |
| Now you can hack on it: cd \"$HERE/$PROJECT\" | |
| Don't worry about messing things up, CB lives elsewhere. | |
| And do check out http://www.chicagoboss.org for guides, examples and doc. | |
| POST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment