#!/usr/bin/python
from sys import argv, exit

try:
    command = argv[1]
except:
    print 'Invalid number of arguments'
    exit()

if command not in ['init', 'start_swap']:
    print 'Command not supported'
    exit()

function = getattr(__import__('swift_drive.commands.' + command,
                   fromlist=['main']), 'main')
try:
    retval = function()
except BaseException, err:
    if '--debug' in argv:
        raise
    retval = str(err)
exit(retval)
