def parse_args():
    """Parses the command line for user run-time settings.

    Returns:
        dictionary with the following keys::

            user: string user name to search for tweets from
            search: string to search for tweets with
            max_tweets: integer max number of tweets to display
            stream: boolean to stream the tweets instead of printing once
            date: boolean to display the date ahead of the tweet
            time: boolean to display the time ahead of the tweet
            json: boolean to display the tweet's json structure instead
            spam: boolean to skip the anti spam measures
    """

    settings = {
        "max": 3,
        "search": [],
        "stream": False,
        "user": None,
        "date": False,
        "time": False,
        "json": False,
        "spam": False,
    }
    max_set = False
    get_next = False
    for arg in sys.argv[1:]:
        if get_next:
            settings[get_next] = arg
            get_next = False
            continue

        arg_copy = arg
        while arg.startswith("-"):
            arg = "".join(arg[1:])

        if arg == "s":
            settings["stream"] = True
        elif arg == "u":
            get_next = "user"
        elif arg == "d":
            settings["date"] = True
        elif arg == "t":
            settings["time"] = True
        elif arg == "j":
            settings["json"] = True
        elif arg == "n":
            settings["spam"] = True
        elif arg == "h":
            raise SystemExit(__doc__.strip())
        elif not max_set:
            try:
                settings["max"] = int(arg)
                max_set = True
            except (TypeError, __HOLE__):
                settings["search"].append(arg_copy)
        else:
            settings["search"].append(arg_copy)

    if settings["stream"] and not (settings["search"] or settings["user"]):
        raise SystemExit(
            __doc__ + "Streaming requires search phrases or the -u flag"
        )

    return settings
dataset/ETHPy150Open a-tal/pyweet/pyweet/base.py/parse_args