Create and register a command with a parent command.

    Args
    ----
    parent_comand : Command
        The parent command.
    name : str
        Name given to the created Command instance.

    Example
    -------
    .. testcode::

       mygit = Command(name='status')

       @register_command(mygit, 'status')
       def status():
           print 'Nothing to commit.'

    .. doctest::
       :hide:

       >>> mygit.init()
       >>> mygit.parse_args(['status'])
       Nothing to commit.

def register_command(parent_command, name):
    """Create and register a command with a parent command.

    Args
    ----
    parent_comand : Command
        The parent command.
    name : str
        Name given to the created Command instance.

    Example
    -------
    .. testcode::

       mygit = Command(name='status')

       @register_command(mygit, 'status')
       def status():
           print 'Nothing to commit.'

    .. doctest::
       :hide:

       >>> mygit.init()
       >>> mygit.parse_args(['status'])
       Nothing to commit.

    """
    def wrapper(func):
        c = command(name)(func)
        parent_command.add_subcommand(c)
    return wrapper