-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.sh
48 lines (44 loc) · 824 Bytes
/
cli.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
#!/bin/bash
echo "Welcome to the CLI! \
Please use '-p initialise' if it's your first time. \
This CLI must be run in the directory folder of the cloned repository."
usage() {
echo "Usage: $0 \
[-h help] \
[-t run tests] \
[-p run program <initialise|path_to_file>] \
[-a arguments]" 1>&2
exit 1
}
while getopts ":hp:a:t" opt; do
case ${opt} in
h)
usage
;;
p)
p=${OPTARG}
;;
a)
a+=("${OPTARG}")
;;
t)
pytest tests/
;;
\?)
echo "Invalid option"
usage
;;
esac
done
shift $((OPTIND - 1))
# Download data and install main code
if [[ "initialise" == "${p}" ]]; then
pip install -e .
exit 0
fi
# Run Python Program
if [[ -z "${p}" ]]; then
usage
else
python3 -u "${p}" "${a[@]}"
fi