Add usage as well as fix the global install to work properly with node_modules.

This commit is contained in:
me committed 2026-09-12 12:48:22 -07:00
1 parent d70c5d3069
commit bd02d4611a
1 file changed
+50 -9
+50 -9
View File
@@ -5,15 +5,47 @@
## Variables ##
DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
PROG="$(basename -- "${BASH_SOURCE[0]}")"
LOCAL=~/bin
GLOBAL=/usr/local/bin
GLOBAL_SRC=/usr/local/src
name_local="prototype.js"
name_short="nomad"
name_long="nomadic-weather"
name_abs="weather-list"
## Functions ##
function usage {
cat <<- EOF
$PROG [-h] [-g] [a|l|s] [-r]
Install $name_local to the system. Can be local, global, or removed.
Parameters)
h) Display this message.
g) Install globally ($GLOBAL), otherwise local ($LOCAL).
a) Abstract name, unrelated to being nomadic. ($name_abs)
l) Long name, the full name of the project. ($name_long)
s) Short name, the full name of the project. ($name_short)
r) Remove / uninstall the project according to the above flags.
Examples)
- Install to the local user with the abstract name.
$PROG
- Install to all users with all names.
$PROG -alsg
- Remove all instances.
$PROG -alsr && $PROG -alsrg
Happy weather watching! :)
~ Hyperling
EOF
exit $1
}
## Parameters ##
while getopts ":gslarh" arg; do
@@ -42,25 +74,34 @@ if [[ "$abstract" == "Y" || ( -z "$short" && -z "$long" ) ]]; then
fi
cmd=""
if [[ -z "$remove" ]]; then
cmd="cp -v $DIR/prototype.js"
else
cmd="rm -v"
fi
dir="$LOCAL"
src="$DIR"
if [[ "$global" == "Y" ]]; then
dir="$GLOBAL"
cmd="sudo $cmd"
cmd="sudo"
echo "Requesting sudo privileges... "
sudo echo "Success!"
mkdir -pv /usr/local/src
sudo cp -Rv "$DIR" $GLOBAL_SRC/
src="$GLOBAL_SRC/`basename "$DIR"`"
fi
if [[ -z "$remove" ]]; then
cmd="$cmd ln -svf $src/$name_local"
else
cmd="$cmd rm -v"
fi
## Main ##
# Untested
#if [[ "$global" == "Y" && "$remove" == "Y" ]]; then
# sudo rm -rfv "$src"
#fi
for prog in $name; do
mkdir -pv $dir
$cmd $dir/$prog
mkdir -pv "$dir"
$cmd "$dir/$prog"
done
## Finish ##