mirror of
https://github.com/wahyd4/gvm.git
synced 2026-08-09 04:46:19 +10:00
- Remove unecessary $(cat) - switch * to ./* to avoid entries with dashes to be treated as options - replace $* with "$@" - repeating change path serial calls - unecessary if change path is called one (get script)
45 lines
932 B
Bash
Executable File
45 lines
932 B
Bash
Executable File
#!/usr/bin/env bash
|
|
. "$GVM_ROOT/scripts/functions"
|
|
|
|
function show_usage() {
|
|
echo "Usage: gvm linkthis [package-name] [options]"
|
|
echo " -h, --help Display this message."
|
|
echo
|
|
echo "If the [package-name] is provided, it will be used in the path based"
|
|
echo "at \${GOPATH%%:*}/src, e.g.:"
|
|
echo
|
|
echo " gvm linkthis github.com/moovweb/gpkg"
|
|
echo
|
|
echo "If omitted, the [package-name] will be the basename of the current"
|
|
echo "directory, e.g. '$package_name_basename'."
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
package_name="$(basename "$PWD")"
|
|
package_name_basename="$package_name"
|
|
|
|
read_command_line "$@"
|
|
|
|
target="${GOPATH%%:*}/src/$package_name"
|
|
|
|
mkdir -p "$(dirname "$target")"
|
|
ln -sv "$PWD" "$target"
|