equal
deleted
inserted
replaced
22 import pgtoolkit.tools |
22 import pgtoolkit.tools |
23 import sys |
23 import sys |
24 from importlib import import_module |
24 from importlib import import_module |
25 |
25 |
26 |
26 |
27 if len(sys.argv) < 2: |
27 def print_tool_with_short_desc(name): |
28 print(__doc__, end='') |
28 module = import_module('pgtoolkit.tools.' + tool) |
29 sys.exit() |
29 short_desc = module.cls.__doc__.lstrip().splitlines()[0] |
|
30 print(name.ljust(15), '-', short_desc) |
30 |
31 |
31 if sys.argv[1] == '--list': |
|
32 for tool in pgtoolkit.tools.__all__: |
|
33 print(tool) |
|
34 sys.exit() |
|
35 |
32 |
36 tool = sys.argv[1] |
33 if __name__ == '__main__': |
37 tool_args = sys.argv[2:] |
34 if len(sys.argv) < 2: |
|
35 print(__doc__, end='') |
|
36 sys.exit() |
38 |
37 |
39 module = import_module('pgtoolkit.tools.' + tool) |
38 if sys.argv[1].startswith('--'): |
|
39 if sys.argv[1] == '--list': |
|
40 for tool in pgtoolkit.tools.__all__: |
|
41 print_tool_with_short_desc(tool) |
|
42 else: |
|
43 print(__doc__, end='') |
|
44 sys.exit() |
40 |
45 |
41 tool = module.cls() |
46 tool = sys.argv[1] |
42 tool.init(tool_args) |
47 tool_args = sys.argv[2:] |
43 tool.main() |
|
44 |
48 |
|
49 if tool not in pgtoolkit.tools.__all__: |
|
50 print('Unknown tool "%s".\n\nCall "pgtool --list" to get list of all available tools.' % tool) |
|
51 sys.exit() |
|
52 |
|
53 module = import_module('pgtoolkit.tools.' + tool) |
|
54 |
|
55 tool = module.cls() |
|
56 tool.setup(tool_args) |
|
57 tool.main() |
|
58 |