-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathartipy
63 lines (47 loc) · 1.67 KB
/
artipy
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
#!/usr/bin/env python
import sys
version = '0.0.1'
class Colors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
class Commands:
@staticmethod
def list():
"""Lists available commands"""
print(
'LaraFlask Framework' + Colors.OKGREEN + ' %s\n\n' % version + Colors.WARNING + 'Usage:\n ' + Colors.ENDC +
'command [options] [arguments]\n')
print(Colors.WARNING + 'Available commands:' + Colors.ENDC)
methods = [x for x, y in Commands.__dict__.items() if isinstance(y, staticmethod)]
longest_method_name = len(max(methods, key=len))
for method in methods:
print(' ' + Colors.OKGREEN + method + Colors.ENDC + ' ' * (longest_method_name - len(method) + 2) +
Commands.__dict__[method].__func__.__doc__)
@staticmethod
def serve(args):
"""Serve the application on the Python Flask development server"""
print(args)
class CommandHandler:
@staticmethod
def execute(args):
if len(args) == 1:
Commands.list()
return
if not CommandHandler.exists(args[1]):
CommandHandler.print_does_not_exist(args[1])
return
Commands.__dict__[args[1]].__func__(args[2:])
@staticmethod
def exists(command):
return command in Commands.__dict__.keys()
@staticmethod
def print_does_not_exist(command):
print(Colors.FAIL + 'Command "%s" is not defined.' % command + Colors.ENDC)
if __name__ == '__main__':
CommandHandler.execute(sys.argv)