Patrick Williams | df917f8 | 2022-01-06 14:20:58 -0600 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 2 | |
| 3 | import argparse |
| 4 | from importlib import import_module |
| 5 | from typing import List |
| 6 | |
Patrick Williams | df917f8 | 2022-01-06 14:20:58 -0600 | [diff] [blame] | 7 | def main() -> int: |
| 8 | parser = argparse.ArgumentParser(description="Obtain TOF voter metrics") |
| 9 | parser.add_argument( |
| 10 | "--data-directory", |
| 11 | "-d", |
| 12 | help="Data directory (default 'data')", |
| 13 | dest="dir", |
| 14 | default="data", |
| 15 | ) |
| 16 | |
| 17 | subparser = parser.add_subparsers(help="Available subcommands") |
| 18 | |
Patrick Williams | 22b7742 | 2022-01-19 16:33:42 -0600 | [diff] [blame] | 19 | commands = [ |
| 20 | import_module("libvoters.subcmd.analyze-commits"), |
| 21 | import_module("libvoters.subcmd.analyze-reviews"), |
| 22 | import_module("libvoters.subcmd.dump-gerrit"), |
| 23 | import_module("libvoters.subcmd.report"), |
| 24 | ] |
| 25 | commands = [x.subcmd(subparser) for x in commands] # type: ignore |
Patrick Williams | df917f8 | 2022-01-06 14:20:58 -0600 | [diff] [blame] | 26 | |
| 27 | args = parser.parse_args() |
| 28 | |
| 29 | if "cmd" not in args: |
| 30 | print("Missing subcommand!") |
| 31 | return 1 |
| 32 | |
| 33 | return int(args.cmd.run(args)) |