Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

main.py 1.15 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

Dos Santos David's avatar
Dos Santos David committed
5

Dos Santos David's avatar
Dos Santos David committed
6 7 8 9 10
def main():
    argsparser = argparse.ArgumentParser(prog="gogole")

    # top-level parser
    # collection information
11 12 13 14
    argsparser.add_argument(
        "-c", "--collection",
        help="collection to use")

Dos Santos David's avatar
Dos Santos David committed
15 16 17 18 19 20 21 22 23 24 25
    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
26
        choices=analyze_command.ANALYZE_COMMANDS,
Dos Santos David's avatar
Dos Santos David committed
27
        metavar="analyze_type",
Dos Santos David's avatar
Dos Santos David committed
28
        help="can be any of {}".format(", ".join(analyze_command.ANALYZE_COMMANDS))
Dos Santos David's avatar
Dos Santos David committed
29
    )
Dos Santos David's avatar
Dos Santos David committed
30 31 32 33 34 35 36

    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
37 38 39

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

Dos Santos David's avatar
Dos Santos David committed
41 42 43 44


if __name__ == "__main__":
    main()