argparser.py 1 KB
Newer Older
1
import argparse
2 3 4 5 6 7 8
import logging


class EnableVerbose(argparse.Action):
    def __call__(self, parser, namespace, values, option_string=None):
        root = logging.getLogger()
        root.setLevel(logging.DEBUG)
9 10 11 12 13 14


def get_arg_parser():
    """ Creates own arguments parser and return it as an object.
    """
    parser = argparse.ArgumentParser()
15 16 17 18 19 20 21 22 23 24
    parser.add_argument('--resource',
                        nargs=1,
                        action='append',
                        required=True,
                        help='resource format: sockname,[connect/bind],sock_type,ip_address,port'
                       )
    parser.add_argument('--disable-ipv6',
                        action='store_true',
                        help='Disable IPv6 mode of ZMQ sockets'
                       )
25 26 27 28 29
    parser.add_argument('-v', '--verbose',
                        nargs=0,
                        action=EnableVerbose,
                        help="Enables debug mode in logger"
                       )
30
    return parser