|
3 | 3 | See full notice in `LICENSE' |
4 | 4 | """ |
5 | 5 | import os |
6 | | -from PyChecker.projects import libft |
| 6 | +import argparse |
| 7 | +from PyChecker.projects import libft, ft_commandements, other |
| 8 | +# @todo: Add verbose output |
| 9 | +# @todo: Add command line output when ran on --no-gui |
7 | 10 |
|
8 | | -root_path = os.path.dirname(os.path.realpath(__file__)) |
9 | | -libft.check("/tmp/libft", root_path) |
| 11 | + |
| 12 | +def print_header(): |
| 13 | + print("\t42PyChecker Copyright (C) 2018-present Jules Lasne " |
| 14 | + "<jules.lasne@gmail.com>\n\tThis program comes with" |
| 15 | + " ABSOLUTELY NO WARRANTY; for details run with `--show-w'.\n\tThis is free" |
| 16 | + " software, and you are welcome to redistribute it\n\tunder certain" |
| 17 | + " conditions; run with `--show-c' for details.") |
| 18 | + |
| 19 | + |
| 20 | +def main(): |
| 21 | + root_path = os.path.dirname(os.path.realpath(__file__)) |
| 22 | + parser = argparse.ArgumentParser() |
| 23 | + parser.add_argument("-v", "--verbose", help="Increases output verbosity", |
| 24 | + action="store_true") |
| 25 | + parser.add_argument("--no-gui", help="disables the Graphical User Interface", |
| 26 | + action="store_true") |
| 27 | + parser.add_argument("--project", help="Specifies the type of project you want to check", choices=['libft', '42commandements', 'other'], default=None) |
| 28 | + parser.add_argument("--no-libftest", help="Disables Libftest", action="store_true") |
| 29 | + parser.add_argument("--no-maintest", help="Disables Maintest", action="store_true") |
| 30 | + parser.add_argument("--no-moulitest", help="Disables Moulitest", action="store_true") |
| 31 | + parser.add_argument("--no-author", help="Disables author file check", action="store_true") |
| 32 | + parser.add_argument("--no-forbidden-functions", help="Disables forbidden functions check", action="store_true") |
| 33 | + parser.add_argument("--no-makefile", help="Disables Makefile check", action="store_true") |
| 34 | + parser.add_argument("--no-norm", help="Disables norm check", action="store_true") |
| 35 | + parser.add_argument("--no-static", help="Disables static functions check", action="store_true") |
| 36 | + parser.add_argument("-p", "--path", help="The path of the project you want to test.", default="", type=str) |
| 37 | + parser.add_argument("--show-w", help="Displays the warranty warning from the license.", action="store_true") |
| 38 | + parser.add_argument("--show-c", help="Displays the conditions warning from the license.", action="store_true") |
| 39 | + args = parser.parse_args() |
| 40 | + if args.show_w: |
| 41 | + print_header() |
| 42 | + print("THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY" |
| 43 | + " APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING\n" |
| 44 | + " THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM" |
| 45 | + " “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR\n" |
| 46 | + " IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES" |
| 47 | + " OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE\n" |
| 48 | + " ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS" |
| 49 | + " WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME\n" |
| 50 | + " THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.") |
| 51 | + return |
| 52 | + if args.show_c: |
| 53 | + print_header() |
| 54 | + with open(root_path + '/.github/LICENSE.lesser', 'r') as file: |
| 55 | + print(file.read()) |
| 56 | + return |
| 57 | + if args.project is None: |
| 58 | + parser.error("You need to specify a project.") |
| 59 | + if args.path == "": |
| 60 | + parser.error("`--path' needs to be specified in order for 42PyChecker" |
| 61 | + " to know where your project is.") |
| 62 | + if args.no_libftest and args.project != "libft": |
| 63 | + parser.error("`--no-libftest' can only be applied if libft is selected " |
| 64 | + "with `--project'") |
| 65 | + if args.no_maintest and args.project != "libft": |
| 66 | + parser.error("`--no-maintest' can only be applied if libft is selected " |
| 67 | + "with `--project'") |
| 68 | + if args.no_moulitest and args.project != "libft": |
| 69 | + parser.error("`--no-moulitest' can only be applied if libft is selected" |
| 70 | + " with `--project'") |
| 71 | + print_header() |
| 72 | + if args.project == "libft": |
| 73 | + libft.check(root_path, args) |
| 74 | + # @todo: Handle options for 42commandements: No option can be passed (like --no-norm) |
| 75 | + if args.project == "42commandements": |
| 76 | + ft_commandements.check(args) |
| 77 | + # @todo: Handle options for other: No option can be passed (like --no-norm) |
| 78 | + if args.project == "other": |
| 79 | + other.check(root_path, args) |
| 80 | + |
| 81 | + |
| 82 | +if __name__ == '__main__': |
| 83 | + main() |
0 commit comments