pgtool
author Radek Brich <brich.radek@ifortuna.cz>
Tue, 06 May 2014 18:37:41 +0200
changeset 100 d6088dba8fea
child 101 2a2d0d5df03b
permissions -rwxr-xr-x
Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
100
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
     2
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
     3
"""
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
     4
Wrapper script for pgtoolkit tools.
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
     5
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
     6
Usage:
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
     7
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
     8
    pgtool --list
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
     9
        List all available tools.
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    10
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    11
    pgtool <tool_name> <arg_1> <arg_2> ...
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    12
        Run tool. All args except first one are forwarded to the tool.
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    13
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    14
    pgtool schemadiff db1 db2
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    15
        E.g. run schemadiff between db1 and db2.
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    16
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    17
    pgtool schemadiff --help
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    18
        Get help for tool parameters.
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    19
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    20
"""
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    21
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    22
import pgtoolkit.tools
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    23
import sys
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    24
from importlib import import_module
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    25
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    26
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    27
if len(sys.argv) < 2:
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    28
    print(__doc__, end='')
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    29
    sys.exit()
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    30
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    31
if sys.argv[1] == '--list':
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    32
    for tool in pgtoolkit.tools.__all__:
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    33
        print(tool)
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    34
    sys.exit()
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    35
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    36
tool = sys.argv[1]
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    37
tool_args = sys.argv[2:]
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    38
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    39
module = import_module('pgtoolkit.tools.' + tool)
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    40
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    41
tool = module.cls()
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    42
tool.init(tool_args)
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    43
tool.main()
d6088dba8fea Add pgtool wrapper for all tools. Only this script will be installed into system bin.
Radek Brich <brich.radek@ifortuna.cz>
parents:
diff changeset
    44