main.py 1.13 KB
Newer Older
Dos Santos David's avatar
Dos Santos David committed
1 2
import argparse

Dos Santos David's avatar
Dos Santos David committed
3
from gogole.commands import analyze_command, build_command
Dos Santos David's avatar
Dos Santos David committed
4 5


Dos Santos David's avatar
Dos Santos David committed
6

Dos Santos David's avatar
Dos Santos David committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
def main():
    argsparser = argparse.ArgumentParser(prog="gogole")

    # top-level parser
    # collection information
    argsparser.add_argument("-f", "--file", help="input collection file")
    argsparser.add_argument("--stop-words-file", help="stop words list filename")
    subparsers = argsparser.add_subparsers()

    argsparser_analyze = subparsers.add_parser(
        'analyze',
        description="Run an analyze like tokens count or find heap's law parameters",
        help="additional help for analyze",
    )
    argsparser_analyze.add_argument(
        "sub_command",
        nargs='*',
Dos Santos David's avatar
Dos Santos David committed
24
        choices=analyze_command.ANALYZE_COMMANDS,
Dos Santos David's avatar
Dos Santos David committed
25
        metavar="analyze_type",
Dos Santos David's avatar
Dos Santos David committed
26
        help="can be any of {}".format(", ".join(analyze_command.ANALYZE_COMMANDS))
Dos Santos David's avatar
Dos Santos David committed
27
    )
Dos Santos David's avatar
Dos Santos David committed
28 29 30 31 32 33 34

    argsparser_build = subparsers.add_parser(
        'build'
    )

    argsparser_analyze.set_defaults(func=analyze_command.run_analyze)
    argsparser_build.set_defaults(func=build_command.run_build)
Dos Santos David's avatar
Dos Santos David committed
35 36 37

    args = argsparser.parse_args()
    args.func(args)
Dos Santos David's avatar
Dos Santos David committed
38

Dos Santos David's avatar
Dos Santos David committed
39 40 41 42


if __name__ == "__main__":
    main()