#!/bin/bash
# diamond-patterns 2016 Ian Dennis Miller
# http://github.com/iandennismiller/diamond-patterns

PROJECT_NAME="$1"

WORK_PATH=~/Work
WORK_CMD="workon ${PROJECT_NAME}"
EDIT_CMD="subl ."
PROJECT_OPEN_CMD="project-open"

if [ -f ~/.diamond-patterns.conf  ]; then
    source ~/.diamond-patterns.conf
fi

function usage() {
cat <<-EOF
Diamond-Patterns - http://github.com/iandennismiller/diamond-patterns

Usage: project-workon [project-name]

Options:

    -h, --help          output help information

Description:

    project-workon enters a project environment.

EOF
}

function project-workon {
    export PROJECT_NAME
    export WORK_PATH
    export WORK_CMD
    export EDIT_CMD
    exec ${PROJECT_OPEN_CMD}
}

if test $# -lt 1; then
    usage
    exit
fi

while test $# -ne 0; do
    arg=$1; shift
    case $arg in
        -h|--help) usage; exit ;;
        *) project-workon; exit ;;
    esac
done
