aboutsummaryrefslogtreecommitdiff
path: root/pyapdctl
blob: ead50858f614ebfe8b03696439a4a119c98579d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3

import argparse

from pyapd import ctl_client, config


class Client():
    sub_commands = (
        ('ping', ctl_client.Ping()),
        ('add_object', ctl_client.AddObject()),
        )

    def main(self):
        self.parser = argparse.ArgumentParser()
        self.subparsers = self.parser.add_subparsers()
        for name, sub in self.sub_commands:
            s_parser = self.subparsers.add_parser(name, help=sub.help)
            sub.register_arguments(s_parser)
            s_parser.set_defaults(func=sub.invoked)
        self.args = self.parser.parse_args()
        self.args.func(self.args)

if __name__ == "__main__":
    Client().main()