Skip to content

Commit

Permalink
refine the scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
haoel committed Mar 27, 2021
1 parent 2354860 commit 3c577b4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
1 change: 0 additions & 1 deletion scripts/readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}\\\"\""
41 changes: 29 additions & 12 deletions scripts/workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,56 @@ 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
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
vi ${SCRIPT_PATH}/../README.md

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 : You can commit the changes by running the following command line..."
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!"

0 comments on commit 3c577b4

Please sign in to comment.