#! /bin/sh

set -e

path=$1

if test -z "$path"; then
    echo "usage: rock-create-rubylib dirname"
    exit 1
fi

if test "$path" = "--help" || test "$path" = "-h"; then
    echo "usage: rock-create-rubylib dirname"
    exit 1
fi

if test -e "$path"; then
    echo "$path already exists"
    exit 1
fi

base_dir=`dirname $path`
if test -n "$base_dir"; then
    mkdir -p $base_dir
    name=`basename $path`
else
    name=$path
fi

if test -z "$ROCK_TEMPLATE_PREFIX"; then
    ROCK_TEMPLATE_PREFIX=https://github.com/rock-core/base-templates-
    ROCK_TEMPLATE_SUFFIX=.git
fi
git clone ${ROCK_TEMPLATE_PREFIX}ruby_lib${ROCK_TEMPLATE_SUFFIX} $path
cd $path
./config.sh $name

