-
Notifications
You must be signed in to change notification settings - Fork 0
/
fava.py
executable file
·78 lines (53 loc) · 2.24 KB
/
fava.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
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
import sys
import argparse
from app.core.console import runner
def main(shell_arguments):
"""
Verifica a opção utilizado e executa comando correspondente
:param shell_arguments: shell_arguments
:return: void
"""
args = parse_command_line(shell_arguments)
if args.dbmigrate is not None:
runner.migrate(args.dbmigrate)
elif args.dbseed is not None:
runner.run_seed()
elif args.makemigration is not None:
runner.create_migration(args.makemigration)
elif args.makemodel is not None:
runner.create_model(args.makemodel)
elif args.makeseeder is not None:
runner.createSeed(args.makeseeder)
elif args.makecontroller is not None:
runner.create_controller(args.makecontroller)
elif args.makeroute is not None:
runner.create_route(args.makeroute)
elif args.server is not None:
runner.run_server(args.server)
return 0
def parse_command_line(args):
"""
Parse commands for trader tool
"""
description = "Use -h to list all commands."
#
parser = argparse.ArgumentParser(description=description)
# Run server
parser.add_argument('-s', '--server', nargs='?', type=str, help='Run application in development', const='5000')
# Create database
parser.add_argument('-mkmigration', '--makemigration', nargs='?', type=str, help='Create a new migration file')
parser.add_argument('-mkseeder', '--makeseeder', nargs='?', type=str, help='Create a new seeder class')
parser.add_argument('-mkmodel', '--makemodel', nargs='?', type=str, help='Create a new Model file')
# Database Commands
parser.add_argument('-migrate', '--dbmigrate', nargs='?', type=str, help='Run all Migration', const='all')
parser.add_argument('-seed', '--dbseed', nargs='?', type=str, help='Run all database seeds', const='all')
# Create Controllers
parser.add_argument('-mkcontroller', '--makecontroller', nargs='?', type=str, help='Create a new Controller file')
# Create Routes
parser.add_argument('-mkroute', '--makeroute', nargs='?', type=str, help='Create a new Route file')
# Create SECRET_KEY
###
args = parser.parse_args()
return args
if __name__ == '__main__':
sys.exit(main(sys.argv[1]))