This commit is contained in:
joachimschmidt557 2020-03-08 17:49:13 +01:00
parent 3684533903
commit 990c3d437b

48
src
View file

@ -15,6 +15,7 @@ Commands:
ls, list List managed directories
a, add Add a source
rm, remove Remove a source directory
i, install Install a copy of this script into the current directory
Flags:
--help, -h Displays this help
@ -74,7 +75,7 @@ update_zipfile() {
update_item() {
## Updates an individual item
echo "Updating: $3"
echo "src: Updating: $3"
case "$1" in
"git")
update_gitrepo "$2" "$3"
@ -86,7 +87,7 @@ update_item() {
update_zipfile "$2" "$3"
;;
*)
echo "Not a valid source type: $1"
echo "src: Not a valid source type: $1"
errors="$errors $3"
;;
esac
@ -95,7 +96,7 @@ update_item() {
preproc() {
## Preprocess the srcfile (remove comments etc.)
if ! [ -f "$srcfile" ] ; then
echo ".srcfile not found!"
echo "src: .srcfile not found!"
exit 1
fi
@ -116,28 +117,22 @@ update_all() {
update_item "$type" "$url" "$path"
done < "$tmp"
case "$errors" in
"")
;;
*)
echo "Errors occurred during:$updated"
;;
esac
if [ -n "$errors" ]; then
echo "src: Errors occurred during:$updated"
fi
case "$updated" in
"")
echo "Nothing updated"
;;
*)
echo "Updated:$updated"
;;
esac
if [ -n "$updated" ]; then
echo "src: Updated:$updated"
else
echo "src: Nothing updated"
fi
cleanup
}
list_all() {
## Parse srcfile and update everything
## Parse srcfile and list all source directories which should be managed by
## src
preproc
while read -r type url path; do
@ -171,6 +166,16 @@ diff_all() {
cleanup
}
install_into_cd() {
## Install a copy of this script into the current working directory
script_path="$(realpath "$0")"
if install -m755 "$script_path" "$(pwd)"; then
echo "src: Install successful"
else
echo "src: Error during install"
fi
}
case "$1" in
"u"|"update")
update_all
@ -188,6 +193,9 @@ case "$1" in
"d"|"diff")
diff_all
;;
"i"|"install")
install_into_cd
;;
"--help"|"-h")
usage
exit 1
@ -197,7 +205,7 @@ case "$1" in
exit 1
;;
*)
echo "Invalid command or flag"
echo "src: Invalid command or flag"
exit 1
;;
esac