util.py 937 Bytes
Newer Older
janis.streib's avatar
janis.streib committed
1
2
import argparse

3
4
default_server = 'www-net-devel.scc.kit.edu'
default_api_version = '3.0'
janis.streib's avatar
janis.streib committed
5
6
7
8
9
10
11
12
13
14


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',
janis.streib's avatar
janis.streib committed
15
                          help='user API token', required=True)
16
        self.add_argument('--server', '-s', default=default_server,
janis.streib's avatar
janis.streib committed
17
                          help='webapi server')
18
        self.add_argument('--api-version', default=default_api_version,
janis.streib's avatar
janis.streib committed
19
20
21
22
23
24
                          help='webapi version')

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