forked from haoel/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.sh
executable file
·51 lines (35 loc) · 990 Bytes
/
readme.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
pushd `dirname $0` > /dev/null
SCRIPTPATH=`pwd -P`
popd > /dev/null
SCRIPTFILE=`basename $0`
COLOR_INFO='\033[0;36m'
COLOR_NONE='\033[0m'
source ${SCRIPTPATH}/lib/query_problem.sh
function usage()
{
echo -e "Usage: ${0} [file]"
echo -e ""
echo -e "Example:"
echo -e ""
echo -e " ${0} ./LargestNumber.cpp"
echo -e ""
}
if [ $# -lt 1 ] || [[ ! -f ${1} ]]; then
usage
exit 255
fi
DIR=`cd $(dirname ${1}) && pwd -P`
FILE=${DIR}/$(basename ${1})
URL=`grep Source ${FILE} | awk '{print $4}'`
URL=$(echo $URL | sed -e 's/oj\.leetcode\.com/leetcode\.com/g')
get_question_slug ${URL}
query_problem ${URL} ${QUESTION_TITLE_SLUG}
#echo "$QUESTION_CONTENT"
#echo $QUESTION_DIFFICULTY
#echo $QUESTION_TITLE
#echo $QUESTION_ID
#echo $QUESTION_FRONTEND_ID
#echo $QUESTION_CATEGORY
FILE=`echo ${FILE} | sed "s/.*\/algorithms/\.\/algorithms/"`
echo "|${QUESTION_FRONTEND_ID}|[${QUESTION_TITLE}](${URL}) | [C++](${FILE})|${QUESTION_DIFFICULTY}|"