-
Notifications
You must be signed in to change notification settings - Fork 22
/
cmd.sh
executable file
·62 lines (48 loc) · 1.55 KB
/
cmd.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
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
__ScriptVersion="1"
#=== FUNCTION ================================================================
# NAME: usage
# DESCRIPTION: Display usage information.
#===============================================================================
usage ()
{
echo "Usage : $0 [options] COMMAND
This is script for makefile concrete commands.
Commands:
install Install pip
test Test code and show coverage
clean Clean associated files
Options:
-h|help Display this message
-v|version Display script version"
} # ---------- end of function usage ----------
#-----------------------------------------------------------------------
# Handle command line arguments
#-----------------------------------------------------------------------
while getopts ":hv" opt
do
case $opt in
h|help ) usage; exit 0 ;;
v|version ) echo "$0 -- Version $__ScriptVersion"; exit 0 ;;
* ) echo -e "\n Option does not exist : $OPTARG\n"
usage; exit 1 ;;
esac # --- end of case ---
done
if [[ "$1" == "" ]]; then
echo "Missing position parameter: COMMAND"
usage
exit 1
fi
case $1 in
install )
pip install -r requirements.txt
exit $? ;;
test )
coverage run runtests.py && coverage report -m
exit $? ;;
clean )
find . \( -name *.pyc -o -name __pycache__ -o -name .coverage -o -name *,cover\) -delete
exit $? ;;
* ) echo "Invalid command: $1\nPlease use --help/-h to review usage."
exit 1 ;;
esac