This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.py
executable file
·45 lines (36 loc) · 1.59 KB
/
cli.py
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
#!/usr/bin/env python
import argparse
import json
import subprocess
from os import path, chdir
import unittest
import json
parser = argparse.ArgumentParser(description='CLI')
parser.set_defaults(which='all')
subparsers = parser.add_subparsers(help='commands')
subcommand = subparsers.add_parser('test', help='test help')
subcommand.set_defaults(which='test')
subcommand = subparsers.add_parser('build', help='build help')
subcommand.set_defaults(which='build')
subcommand = subparsers.add_parser('deploy-test', help='deploy-test help')
subcommand.set_defaults(which='deploy-test')
subcommand = subparsers.add_parser('deploy-prod', help='deploy-prod help')
subcommand.set_defaults(which='deploy-prod')
args = parser.parse_args()
if args.which == 'test':
tests = unittest.TestLoader().discover('.')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if not result.wasSuccessful():
exit(1)
if args.which == 'build':
subprocess.check_call(['rm', '-rf', 'dist'])
subprocess.check_call(['python', 'setup.py', 'sdist', 'bdist_wheel'])
if args.which == 'deploy-test':
subprocess.check_call(['python', 'cli.py', 'build'])
subprocess.check_call(['python', '-m', 'pip', 'install', '--upgrade', 'twine'])
subprocess.check_call(['python', '-m', 'twine', 'upload', '--repository-url', 'https://test.pypi.org/legacy/', 'dist/*'])
if args.which == 'deploy-prod':
subprocess.check_call(['python', 'cli.py', 'build'])
subprocess.check_call(['python', '-m', 'pip', 'install', '--upgrade', 'twine'])
subprocess.check_call(['python', '-m', 'twine', 'upload', 'dist/*'])
exit(0)