#!/usr/bin/env python
import argparse
from pg_chameleon import replica_engine
commands = [
					'create_schema',
					'init_replica',
					'start_replica',
					'upgrade_schema',
					'drop_schema', 
					'list_config', 
					'add_source', 
					'drop_source', 
					'stop_replica', 
					'disable_replica', 
					'enable_replica', 
					'sync_replica', 
					'show_status'

	]
command_help = 'Available commands, ' + ','.join(commands)

parser = argparse.ArgumentParser(description='Command line for pg_chameleon.',  add_help=True)
parser.add_argument('command', metavar='command', type=str, help=command_help)
parser.add_argument('--config', metavar='config', type=str,  default='default',  required=False)

args = parser.parse_args()

if args.command in commands:
	replica = replica_engine(args.config)
	if args.command == commands[0]:
		replica.create_service_schema()
	elif args.command == commands[1]:
		replica.init_replica()
	elif args.command == commands[2]:
		replica.run_replica()
	elif args.command == commands[3]:
		replica.upgrade_service_schema()
	elif args.command == commands[4]:
		replica.drop_service_schema()
	elif args.command == commands[5]:
		replica.list_config()
	elif args.command == commands[6]:
		replica.add_source()
	elif args.command == commands[7]:
		replica.drop_source()
	elif args.command == commands[8]:
		replica.stop_replica()
	elif args.command == commands[9]:
		replica.stop_replica(allow_restart=False)
	elif args.command == commands[10]:
		replica.enable_replica()
	elif args.command == commands[11]:
		replica.sync_replica()
	elif args.command == commands[12]:
		replica.show_status()

#!/usr/bin/env python
import argparse
from pg_chameleon import replica_engine
commands = [
					'create_schema',
					'init_replica',
					'start_replica',
					'upgrade_schema',
					'drop_schema', 
					'list_config', 
					'add_source', 
					'drop_source', 
					'stop_replica', 
					'disable_replica', 
					'enable_replica', 
					'sync_replica', 
					'show_status', 
					'list_tables'

	]
command_help = 'Available commands, ' + ','.join(commands)

parser = argparse.ArgumentParser(description='Command line for pg_chameleon.',  add_help=True)
parser.add_argument('command', metavar='command', type=str, help=command_help)
parser.add_argument('--config', metavar='config', type=str,  default='default',  required=False)
parser.add_argument('--table', metavar='table', type=str,  default='all',  required=False)

args = parser.parse_args()

if args.command in commands:
	replica = replica_engine(args.config)
	if args.command == commands[0]:
		replica.create_service_schema()
	elif args.command == commands[1]:
		replica.init_replica()
	elif args.command == commands[2]:
		replica.run_replica()
	elif args.command == commands[3]:
		replica.upgrade_service_schema()
	elif args.command == commands[4]:
		replica.drop_service_schema()
	elif args.command == commands[5]:
		replica.list_config()
	elif args.command == commands[6]:
		replica.add_source()
	elif args.command == commands[7]:
		replica.drop_source()
	elif args.command == commands[8]:
		replica.stop_replica()
	elif args.command == commands[9]:
		replica.stop_replica(allow_restart=False)
	elif args.command == commands[10]:
		replica.enable_replica()
	elif args.command == commands[11]:
		replica.sync_replica()
	elif args.command == commands[12]:
		replica.show_status()
	elif args.command == commands[13]:
		replica.list_tables()

add support for single table resync