refine the scripts
This commit is contained in:
parent
23548607d0
commit
3c577b4cd4
@ -50,4 +50,3 @@ FILE=`echo ${FILE} | sed "s/.*\/algorithms/\.\/algorithms/"`
|
||||
|
||||
echo "|${QUESTION_FRONTEND_ID}|[${QUESTION_TITLE}](${URL}) | [C++](${FILE})|${QUESTION_DIFFICULTY}|"
|
||||
|
||||
echo "git commit -am \"New Problem Solution -\\\"${QUESTION_TITLE}\\\"\""
|
@ -36,27 +36,24 @@ platform=`detect_os`
|
||||
leetcode_url=$1
|
||||
|
||||
get_question_slug ${leetcode_url}
|
||||
|
||||
dir_name=`echo ${QUESTION_TITLE_SLUG} | awk -F '-' '{for (i=1; i<=NF; i++) printf("%s", toupper(substr($i,1,1)) substr($i,2)) }'`
|
||||
|
||||
dir_name=`echo ${dir_name:0:1} | tr '[A-Z]' '[a-z]'`${dir_name:1}
|
||||
|
||||
mkdir -p ${dir_name}
|
||||
echo "Step 1 : Created \"${dir_name}\" directory!"
|
||||
cd ${dir_name}
|
||||
WORKING_DIR=`pwd`
|
||||
|
||||
file=`${SCRIPT_PATH}/comments.sh ${leetcode_url} | grep updated | awk '{print $1}'`
|
||||
echo "Step 2 : Created \"${dir_name}/${file}\" source file!"
|
||||
|
||||
git add ${file}
|
||||
|
||||
echo "Step 3 : Run \"git add ${dir_name}/${file}\"!"
|
||||
git add ${file}
|
||||
|
||||
vi "${file}"
|
||||
echo "Step 4 : Edited the \"${dir_name}${file}\"!"
|
||||
|
||||
output=`${SCRIPTPATH}/readme.sh ${file}`
|
||||
readme=`echo "${output}" | head -n 1`
|
||||
commit=`echo "${output}" | tail -n 1`
|
||||
readme=`${SCRIPT_PATH}/readme.sh ${file}`
|
||||
readme=`echo "${readme}" | head -n 1`
|
||||
|
||||
if [[ "$platform" == "macos" ]]; then
|
||||
echo $readme | pbcopy
|
||||
@ -64,11 +61,31 @@ else
|
||||
echo $readme
|
||||
read -n 1 -s -r -p "Please copy the line above & press any key continue to edit README.md"
|
||||
fi
|
||||
|
||||
echo "Step 5 : Copied the readme text to Clipboard!"
|
||||
vi ${SCRIPTPATH}/../README.md
|
||||
echo "Step 6 : Edited the \"README.md\"!"
|
||||
vi ${SCRIPT_PATH}/../README.md
|
||||
|
||||
echo "Step 7 : You can commit the changes by running the following command line..."
|
||||
echo "Step 6 : Edited the \"README.md\"!"
|
||||
QUESTION_TITLE=`echo "${readme}" | awk -F '|' '{print $3}' | sed 's/\[/\]/' |awk -F ']' '{print $2}'`
|
||||
commit="git commit -m \"New Problem Solution -\\\"${QUESTION_TITLE}\\\"\""
|
||||
|
||||
echo "Step 7 : It's ready to commit to git repository ..."
|
||||
echo ""
|
||||
echo " ${commit}"
|
||||
echo " ${commit} \\"
|
||||
echo " ${WORKING_DIR}/${file} \\"
|
||||
echo " ${SCRIPT_PATH}/../README.md"
|
||||
echo ""
|
||||
|
||||
#git status
|
||||
|
||||
commit="${commit} \"${WORKING_DIR}/${file}\" \"${SCRIPT_PATH}/../README.md\""
|
||||
|
||||
while true; do
|
||||
read -p "Do you wish to commit them (y/n) ?" yn
|
||||
case $yn in
|
||||
[Yy]* ) echo "/bin/bash -c ${commit}"; break;;
|
||||
[Nn]* ) exit;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "Done!"
|
Loading…
x
Reference in New Issue
Block a user