-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool.sh
executable file
·51 lines (40 loc) · 967 Bytes
/
tool.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
function usage {
local tool=$(basename $0)
cat <<EOF
USAGE:
$ $tool [-h|--help] COMMAND
EXAMPLES:
$ $tool readme Generate README.rst from README.md
$ $tool test Upload release to testpypi
$ $tool prod Upload release to prod pypi
EOF
exit 1;
}
# convert README.md to README.rst
function readme {
pandoc --from=markdown --to=rst --output=README.rst README.md
printf 'README.rst generated';
}
# total arguments should be 1
if [ $# -ne 1 ]; then
usage;
fi
if { [ -z "$1" ] && [ -t 0 ] ; } || [ "$1" == '-h' ] || [ "$1" == '--help' ]
then
usage;
fi
# show help for no arguments if stdin is a terminal
if [ "$1" == "readme" ]; then
readme
elif [ "$1" == "test" ]; then
readme
# build and upload package to test pypi
python setup.py sdist upload -r pypitest
elif [ "$1" == "prod" ]; then
readme
# build and upload package to prod pypi
python setup.py sdist upload -r pypi
else
usage;
fi