@@ -36,39 +36,56 @@ platform=`detect_os`
36
36
leetcode_url=$1
37
37
38
38
get_question_slug ${leetcode_url}
39
-
40
39
dir_name=` echo ${QUESTION_TITLE_SLUG} | awk -F ' -' ' {for (i=1; i<=NF; i++) printf("%s", toupper(substr($i,1,1)) substr($i,2)) }' `
41
-
42
40
dir_name=` echo ${dir_name: 0: 1} | tr ' [A-Z]' ' [a-z]' ` ${dir_name: 1}
43
41
44
42
mkdir -p ${dir_name}
45
43
echo " Step 1 : Created \" ${dir_name} \" directory!"
46
44
cd ${dir_name}
45
+ WORKING_DIR=` pwd`
47
46
48
47
file=` ${SCRIPT_PATH} /comments.sh ${leetcode_url} | grep updated | awk ' {print $1}' `
49
48
echo " Step 2 : Created \" ${dir_name} /${file} \" source file!"
50
-
51
- git add ${file}
49
+
52
50
echo " Step 3 : Run \" git add ${dir_name} /${file} \" !"
51
+ git add ${file}
53
52
54
53
vi " ${file} "
55
54
echo " Step 4 : Edited the \" ${dir_name}${file} \" !"
56
-
57
- output=` ${SCRIPTPATH} /readme.sh ${file} `
58
- readme=` echo " ${output} " | head -n 1`
59
- commit=` echo " ${output} " | tail -n 1`
55
+ readme=` ${SCRIPT_PATH} /readme.sh ${file} `
56
+ readme=` echo " ${readme} " | head -n 1`
60
57
61
58
if [[ " $platform " == " macos" ]]; then
62
59
echo $readme | pbcopy
63
60
else
64
61
echo $readme
65
62
read -n 1 -s -r -p " Please copy the line above & press any key continue to edit README.md"
66
63
fi
67
-
68
64
echo " Step 5 : Copied the readme text to Clipboard!"
69
- vi ${SCRIPTPATH} /../README.md
65
+ vi ${SCRIPT_PATH} /../README.md
66
+
70
67
echo " Step 6 : Edited the \" README.md\" !"
68
+ QUESTION_TITLE=` echo " ${readme} " | awk -F ' |' ' {print $3}' | sed ' s/\[/\]/' | awk -F ' ]' ' {print $2}' `
69
+ commit=" git commit -m \" New Problem Solution -\\\" ${QUESTION_TITLE} \\\"\" "
71
70
72
- echo " Step 7 : You can commit the changes by running the following command line ..."
71
+ echo " Step 7 : It's ready to commit to git repository ..."
73
72
echo " "
74
- echo " ${commit} "
73
+ echo " ${commit} \\ "
74
+ echo " ${WORKING_DIR} /${file} \\ "
75
+ echo " ${SCRIPT_PATH} /../README.md"
76
+ echo " "
77
+
78
+ # git status
79
+
80
+ commit=" ${commit} \" ${WORKING_DIR} /${file} \" \" ${SCRIPT_PATH} /../README.md\" "
81
+
82
+ while true ; do
83
+ read -p " Do you wish to commit them (y/n) ?" yn
84
+ case $yn in
85
+ [Yy]* ) echo " /bin/bash -c ${commit} " ; break ;;
86
+ [Nn]* ) exit ;;
87
+ * ) echo " Please answer yes or no." ;;
88
+ esac
89
+ done
90
+
91
+ echo " Done!"
0 commit comments