File size: 1,068 Bytes
815b0dc
 
 
41baea7
815b0dc
683946e
815b0dc
 
 
 
 
 
 
 
 
 
 
 
 
41baea7
683946e
815b0dc
 
 
 
 
 
 
 
 
 
 
 
376cfc2
815b0dc
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import argparse

from .. import __version__
from .create import CreateCompetitionAppCommand
from .run import RunCompetitionsAppCommand
from .submit import SubmitCompetitionAppCommand


def main():
    parser = argparse.ArgumentParser(
        "Competitions CLI",
        usage="competitions <command> [<args>]",
        epilog="For more information about a command, run: `competitions <command> --help`",
    )
    parser.add_argument("--version", "-v", help="Display competitions version", action="store_true")
    commands_parser = parser.add_subparsers(help="commands")

    # Register commands
    RunCompetitionsAppCommand.register_subcommand(commands_parser)
    CreateCompetitionAppCommand.register_subcommand(commands_parser)
    SubmitCompetitionAppCommand.register_subcommand(commands_parser)

    args = parser.parse_args()

    if args.version:
        print(__version__)
        exit(0)

    if not hasattr(args, "func"):
        parser.print_help()
        exit(1)

    command = args.func(args)
    command.run()


if __name__ == "__main__":
    main()