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 | d0269de | 2022-01-06 21:04:25 -0600 | [diff] [blame^] | 7 | subcommands = [ |
| 8 | "analyze-commits", |
| 9 | "analyze-reviews", |
| 10 | "dump-gerrit", |
| 11 | ] |
Patrick Williams | df917f8 | 2022-01-06 14:20:58 -0600 | [diff] [blame] | 12 | |
| 13 | |
| 14 | def main() -> int: |
| 15 | parser = argparse.ArgumentParser(description="Obtain TOF voter metrics") |
| 16 | parser.add_argument( |
| 17 | "--data-directory", |
| 18 | "-d", |
| 19 | help="Data directory (default 'data')", |
| 20 | dest="dir", |
| 21 | default="data", |
| 22 | ) |
| 23 | |
| 24 | subparser = parser.add_subparsers(help="Available subcommands") |
| 25 | |
| 26 | commands = [] |
| 27 | for c in subcommands: |
| 28 | commands.append( |
| 29 | import_module("libvoters.subcmd." + c).subcmd(subparser) # type: ignore |
| 30 | ) |
| 31 | |
| 32 | args = parser.parse_args() |
| 33 | |
| 34 | if "cmd" not in args: |
| 35 | print("Missing subcommand!") |
| 36 | return 1 |
| 37 | |
| 38 | return int(args.cmd.run(args)) |