This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage
executable file
·86 lines (73 loc) · 1.46 KB
/
manage
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
# define tasks here
get_current_job (){
ls -lhtr python | tail -n 1 | awk '{print $NF}'
}
init () {
exercism fetch
current=$(get_current_job)
file_prefix=`echo $current | sed "s/-/_/g"`
echo -e "#!/usr/bin/env python\n#encoding=utf8\n\n" > /tmp/exercism.tmp
cat python/$current/${file_prefix}.py >> /tmp/exercism.tmp
mv /tmp/exercism.tmp python/$current/${file_prefix}.py
}
test (){
current=$(get_current_job)
file_prefix=`echo $current | sed "s/-/_/g"`
python2 python/$current/${file_prefix}_test.py
python3 python/$current/${file_prefix}_test.py
}
run() {
current=$(get_current_job)
file_prefix=`echo $current | sed "s/-/_/g"`
python python/$current/${file_prefix}.py
}
submit () {
current=$(get_current_job)
file_prefix=`echo $current | sed "s/-/_/g"`
exercism submit python/$current/${file_prefix}.py
git add "python/$(get_current_job)"
git commit -vs
init
}
_less () {
current=$(get_current_job)
less python/$current/README.md
}
cheat () {
current=$(get_current_job)
file_prefix=`echo $current | sed "s/-/_/g"`
cat python/$current/${file_prefix}_test.py
}
clean (){
echo "do clean here"
}
# main start here
command=${1:-""}
if [ -n "$(type -t $command)" ] && [ "$(type -t $command)" = function ]
then
eval $command
exit $?
fi
case "$command" in
i)
init
;;
l)
_less
;;
r)
run
;;
s)
submit
;;
t)
test
;;
*)
clean
esac