From 24e475d6ff44f13f15c9225f19c14ba8eb786dba Mon Sep 17 00:00:00 2001 From: Rafe Colton Date: Wed, 24 Jul 2013 13:15:39 -0400 Subject: [PATCH] Adding `gvm linkthis` command This links the current project into the $GOPATH/src to allow `go get` to find the local development copy instead of the one on GitHub (or wherever) Signed-off-by: Dan Buch --- scripts/linkthis | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 scripts/linkthis diff --git a/scripts/linkthis b/scripts/linkthis new file mode 100755 index 0000000..c3acc4d --- /dev/null +++ b/scripts/linkthis @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +. $GVM_ROOT/scripts/functions + +function show_usage() { + echo "Usage: gvm linkthis [options]" + echo " -h, --help Display this message." +} + +package_name="$(basename "$PWD")" + +function read_command_line() { + for i in $*; do + case $i in + -h|--help*) + show_usage + exit 0 + ;; + -*|--*) + echo "Invalid option $i" + show_usage + exit 65 # Bad arguments + ;; + *) + package_name="$i" + ;; + esac + done +} + +read_command_line "$@" + +target="${GOPATH%%:*}/src/$package_name" + +mkdir -p "$(dirname "$target")" +ln -sv "$PWD" "$target"