Parse and run commands.
    
    Will search ``namespace`` for functions that end with ``command_suffix``.
    
    :param namespace: the namespace/module to search for commands
    :param args: the arguments for the command parser. defaults to
        :data:`sys.argv`
    :param command_suffix: function name suffix that indicates that a
        function is a command.

def autocmds(namespace=None, args=None, command_suffix='_command',
        add_dry_run_option=True, add_verbosity_option=True):
    """
    Parse and run commands.
    
    Will search ``namespace`` for functions that end with ``command_suffix``.
    
    :param namespace: the namespace/module to search for commands
    :param args: the arguments for the command parser. defaults to
        :data:`sys.argv`
    :param command_suffix: function name suffix that indicates that a
        function is a command.
    """
    if namespace is None:
        namespace = inspect.currentframe().f_back.f_globals
    elif type(namespace) is types.ModuleType:
        namespace = namespace.__dict__
    
    if args is None:
        args = sys.argv
    
    if len(args) < 2 or args[1] in ('-h', '--help'):
        print_help(namespace, command_suffix)
        return
    
    command_name = args.pop(1).replace('-', '_')
    function = namespace[command_name + command_suffix]
    parse_and_run_function(function, args, command_name,
        add_dry_run_option=add_dry_run_option,
        add_verbosity_option=add_verbosity_option)