#!/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()