Last active
August 6, 2019 03:16
-
-
Save apmiller108/ad5bb208828b2d97f5b09d0c7a90c459 to your computer and use it in GitHub Desktop.
Revisions
-
apmiller108 revised this gist
Mar 18, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,9 +40,9 @@ echo -e -n "Please confirm this is correct:\n"\ read -p "" ANSWER if [ "$ANSWER" = "y" ]; then grep -l $CURRENT_NAME -r . --exclude-dir=_build \ | xargs sed -i '' -e "s/$CURRENT_NAME/$NEW_NAME/g" grep -l $CURRENT_OTP -r . --exclude-dir=_build \ | xargs sed -i '' -e "s/$CURRENT_OTP/$NEW_OTP/g" mv lib/$CURRENT_OTP lib/$NEW_OTP -
apmiller108 revised this gist
Mar 18, 2017 . 1 changed file with 21 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,32 +3,39 @@ set -e set -o pipefail CURRENT_OTP=$1 NEW_OTP=$2 CURRENT_NAME="" NEW_NAME="" # New name and current name arguments are required if [ $# -ne 2 ]; then echo -e "Please provide the current name and new name in snake case\n"\ "usage: /.rename_phoenix_app.sh current_name new_name" exit 64 fi # Split snake cased names into array of words. IFS="_" read -a current_name_words <<< "$CURRENT_OTP" IFS="_" read -a new_name_words <<< "$NEW_OTP" # Upercase all the words and concatenate them together to derive the CamelCase # module names for word in "${current_name_words[@]}"; do word="$(tr '[:lower:]' '[:upper:]' <<< ${word:0:1})${word:1}" CURRENT_NAME="$CURRENT_NAME$word" done for word in "${new_name_words[@]}"; do word="$(tr '[:lower:]' '[:upper:]' <<< ${word:0:1})${word:1}" NEW_NAME="$NEW_NAME$word" done # Confirm name change echo -e -n "Please confirm this is correct:\n"\ "Change $CURRENT_OTP to $NEW_OTP?\n"\ "Change $CURRENT_NAME to $NEW_NAME?\n"\ "Continue? [y/n]" read -p "" ANSWER -
apmiller108 created this gist
Mar 18, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ #!/bin/bash set -e set -o pipefail NEW_OTP=$1 NEW_NAME="" # New name argument is required if [ $# -eq 0 ]; then echo "Please provide a name in snake case. See readme for instructions"\ "https://github.com/apmiller108/phoenix_starter/blob/master/README.md" exit 64 fi CURRENT_NAME="PhoenixStarter" CURRENT_OTP="phoenix_starter" # Split snake cased new name into array of words. IFS="_" read -a words <<< "$NEW_OTP" # Upercase all the words and concatenate them together. This derives the app's # CamelCase module name. for word in "${words[@]}"; do word="$(tr '[:lower:]' '[:upper:]' <<< ${word:0:1})${word:1}" NEW_NAME="$NEW_NAME$word" done # Confirm name change echo -e -n "Please confirm this is correct:\nNew name: ${NEW_NAME}\n"\ "New OTP name: $NEW_OTP\nContinue? [y/n]" read -p "" ANSWER if [ "$ANSWER" = "y" ]; then grep -l $CURRENT_NAME -r . --exclude-dir=_build --exclude README.md \ | xargs sed -i '' -e "s/$CURRENT_NAME/$NEW_NAME/g" grep -l $CURRENT_OTP -r . --exclude-dir=_build --exclude README.md \ | xargs sed -i '' -e "s/$CURRENT_OTP/$NEW_OTP/g" mv lib/$CURRENT_OTP lib/$NEW_OTP mv lib/$CURRENT_OTP.ex lib/$NEW_OTP.ex echo -e "Completed renaming" else echo -e "exiting" exit 0 fi