util.py 890 Bytes
Newer Older
janis.streib's avatar
janis.streib committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import argparse

server = 'www-net-devel.scc.kit.edu'
api_version = '3.0'


class ArgumentParser(argparse.ArgumentParser):
    """Argument parser with default common arguments for NetDB-api cli
    tools. Includes default values."""
    def __init__(self, formatter_class=argparse.ArgumentDefaultsHelpFormatter,
                 **kwargs):
        super(ArgumentParser, self).__init__(formatter_class=formatter_class,
                                             **kwargs)
        self.add_argument('--token', '-t',
                          help='user API token')
        self.add_argument('--server', '-s', default=server,
                          help='webapi server')
        self.add_argument('--api-version', default=api_version,
                          help='webapi version')

    def parse_args(self):
        args = super(ArgumentParser, self).parse_args()
        return args