Skip to content

Commit

Permalink
fixing init.sh rename script
Browse files Browse the repository at this point in the history
  • Loading branch information
quffaro committed Jul 24, 2024
1 parent 8cbf596 commit 2bc7f95
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
DEFAULT_REPO='AlgebraicTemplate'
DEFAULT_UUID='b66562e1-fa90-4e8b-9505-c909188fab76'

usage="This script is for initializing the template with the new repository name and UUID. Please provide the new repository name and UUID in that order. The repository name cannot be 'Test.'\n
usage="This script is for initializing the template with the new repository name and UUID. Please provide the new repository name and UUID in that order. The repository name cannot be 'Test'.\n
Example:\n
./init.sh ${DEFAULT_REPO} ${DEFAULT_UUID}"

REPO=${1:-"${PWD##*/}"}
REPO=${REPO%%.jl*}
UUID=${2:-$(uuidgen)}

# set to lowercase
Expand All @@ -19,6 +20,11 @@ if [ ! $REPO ] || [ "$REPO" = 'Test' ] || [ ! $UUID ]; then
exit 1
fi

if [[ ! "$REPO" =~ ^[a-zA-Z]+$ ]]; then
echo "The string '$REPO' contains non-alphabetic characters."
exit 1
fi

read -p "By continuing, the following substitutions will be made:
REPO: $DEFAULT_REPO => $REPO
Expand Down Expand Up @@ -49,12 +55,7 @@ case "${unameOut}" in
esac

# rename
if [[ $REPO == *.jl ]]
then
mv src/$DEFAULT_REPO.jl src/$REPO
else
mv src/$DEFAULT_REPO.jl src/$REPO.jl
fi
mv src/$DEFAULT_REPO.jl src/$REPO.jl

read -p "Would you like this script to add, commit, and push the new changes? [y/N]" -n 1 -r -s
echo
Expand Down

0 comments on commit 2bc7f95

Please sign in to comment.