#!/usr/bin/env python
"""

Main command for PyPe9 package, which can be used to invoke all PyPe9
functionality in a similar style to the 'git' or 'svn' commands, e.g.

    pype9 simulate <simulation.xml> 100.0

or

    pype9 convert --version 2.0 <v1.xml> <v2.xml>

"""
import sys
from copy import copy
from argparse import ArgumentParser
import pype9.cmd

parser = ArgumentParser(__doc__)
parser.add_argument('cmd', choices=pype9.cmd.help.all_cmds(),
                    help=("PyPe9 command to run. {}"
                          .format(pype9.cmd.help.available_cmds_message())))
args = parser.parse_args(sys.argv[1:2] if len(sys.argv) >= 2 else [])

# Copy and clear sys.argv as it gets in the way of pyNEST import
argv = copy(sys.argv[2:])
del sys.argv[1:]
getattr(pype9.cmd, args.cmd).run(argv)
