cli.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:pingparsing 作者: thombashi 项目源码 文件源码
def parse_option():
    parser = argparse.ArgumentParser()
    if is_use_stdin():
        parser.add_argument(
            "destination_or_file", nargs="+",
            help="")

    parser.add_argument(
        "--max-workers", type=int,
        help="""a number of threads for when multiple destination/file
        specified. defaults to equals to two times number of cores.
        """)
    parser.add_argument(
        "--indent", type=int, default=4,
        help="""JSON output will be pretty-printed with the indent level.
        (default= %(default)s)
        """)

    loglevel_dest = "log_level"
    group = parser.add_mutually_exclusive_group()
    group.add_argument(
        "--debug", dest=loglevel_dest, action="store_const",
        const=logbook.DEBUG, default=logbook.INFO,
        help="for debug print.")
    group.add_argument(
        "--quiet", dest=loglevel_dest, action="store_const",
        const=logbook.NOTSET, default=logbook.INFO,
        help="suppress execution log messages.")

    group = parser.add_argument_group("Ping Options")
    group.add_argument(
        "-c", "--count", type=int,
        help="""stop after sending the count.
        see also ping(8) [-c count] option description.
        """)
    group.add_argument(
        "-w", "--deadline", type=float,
        help="""timeout in seconds.
        see also ping(8) [-w deadline] option description.
        """)
    group.add_argument(
        "-I", "--interface", dest="interface",
        help="network interface")

    return parser.parse_args()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号