return argv as a parsed dictionary, looks like the following:

    app --option1 likethis --option2 likethat --flag

    ->

    {'option1': 'likethis', 'option2': 'likethat', 'flag': True}

def _parse_argv(argv=copy(sys.argv)):
    """return argv as a parsed dictionary, looks like the following:

    app --option1 likethis --option2 likethat --flag

    ->

    {'option1': 'likethis', 'option2': 'likethat', 'flag': True}
    """

    cfg = DotDict()
    cfg_files = []

    argv = argv[1:] # Skip command name
    while argv:
        arg = argv.pop(0)

        # split up arg in format --arg=val
        key_val = re.split('=| ', arg)
        arg = key_val[0]
        try:
            val = key_val[1]
        except IndexError:
            if len(argv) > 0 and argv[0][0] != '-':
                val = argv.pop(0)
            else:
                # No val available, probably a flag
                val = None

        if arg[0] == '-':
            key = arg.lstrip('-')
            if not val:
                val = True
            new_cfg = _dict_from_dotted(key, val)
            cfg = dict_merge(cfg, new_cfg)
        else:
            if arg.endswith(".yml"):
                cfg_files.append(arg)

    return cfg, cfg_files