#!/usr/bin/env python
VERSION=(1,0,0,)
import sys
from . import cli
from . import vote
def main():
_self = sys.argv[0]
_config, _positionals = cli.main(sys.argv[1:])
if "version" in _config.keys():
sys.stderr.write(f"{_self}: {'.'.join(str(v) for v in VERSION)}\n")
sys.exit(0)
elif "help" in _config.keys():
sys.stderr.write(f"Usage: {_self} [OPTIONS]\n")
sys.stderr.write(f"Options:\n")
sys.stderr.write(f" -c=N, --candidates=N number of candidates [Default: 3]\n")
sys.stderr.write(f" -h, -x, --help print this message and exit\n")
sys.stderr.write(f" -r=N, --representatives=N number of voting representatives [Default: 221]\n")
sys.stderr.write(f" -t=N, --trials=N number of trials to run [Default: 1]\n")
sys.stderr.write(f" -v, -V, --version print version and exit\n")
sys.exit(0)
_candidates = int(_config.get("candidates", 3))
_representatives = int(_config.get("representatives", 221))
_trials = int(_config.get("trials", 3))
if _trials == 1:
vote.run1(_candidates, _representatives)
else:
vote.runmany(_candidates, _representatives, _trials)
if __name__ == '__main__':
main()