Commit 42cdf17e authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Polish the rename script

Also replace occurences of "Example" with a capital E, and play nice
with accronym names:

   ./rename-vmod-script aweaome
   # renames the module to libvmod-awesome
   # replaces Example by Awesome

   ./rename-vmod-script WTF
   # renames the module to libvmod-wtf
   # replaces Example by WTF
parent 9084429e
......@@ -14,24 +14,31 @@ NAME=$1
if [ -z "$NAME" ]; then
echo "Usage: $0 <new-vmod-name-without-libvmod-prefix>"
echo "Rename libvmod-example source tree."
echo "If the name is an acronym, you can use capital letters."
echo
exit -1
fi
SYM_NAME=${NAME,,*}
CAP_NAME=${NAME^?}
if ! git diff-index --quiet HEAD --; then
echo "ERROR: Need a clean working tree. Run \"git stash\" first."
exit -2
fi
git mv src/vmod_example.c src/vmod_${NAME}.c
git mv src/vmod_example.vcc src/vmod_${NAME}.vcc
git mv vmod-example.spec vmod-${NAME}.spec
git mv src/vmod_example.c src/vmod_${SYM_NAME}.c
git mv src/vmod_example.vcc src/vmod_${SYM_NAME}.vcc
git mv vmod-example.spec vmod-${SYM_NAME}.spec
git grep -z -l example | xargs -0 sed -i -s -e "s/example/${NAME}/g"
git grep -z -l example | xargs -0 sed -i -s -e "s/example/${SYM_NAME}/g"
git grep -z -l Example | xargs -0 sed -i -s -e "s/Example/${CAP_NAME}/g"
git rm -f rename-vmod-script
echo "All done."
echo -e "For your cut&paste needs:\n git commit -a -m \"Automatic rename of libvmod-example to libvmod-${NAME}.\""
cat <<EOF
All done.
For your cut&paste needs:
git commit -a -m "Automatic rename of libvmod-example to libvmod-${SYM_NAME}."
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment