From 7081b93b8ed4f98c628400e05d22d0523f41a842 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 27 Feb 2021 12:24:37 +0100 Subject: Fixing #16 - Adding support for custom config file in user directory --- minishell_test/args.py | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) (limited to 'minishell_test/args.py') diff --git a/minishell_test/args.py b/minishell_test/args.py index ef47081..3f56b8c 100644 --- a/minishell_test/args.py +++ b/minishell_test/args.py @@ -6,16 +6,16 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:32 by charles #+# #+# # -# Updated: 2021/02/24 08:48:15 by cacharle ### ########.fr # +# Updated: 2021/02/27 12:08:55 by cacharle ### ########.fr # # # # ############################################################################ # import argparse import textwrap - -import minishell_test.config as config +import functools +@functools.lru_cache(maxsize=1) def parse_args(): """Parse command line arguments""" @@ -25,65 +25,64 @@ def parse_args(): epilog="Made by cacharle - https://cacharle.xyz" ) parser.add_argument( - "-p", "--path", default=config.MINISHELL_DIR, + "-p", "--path", + default=".", help="Path to minishell directory" ) parser.add_argument( - "-l", "--list", action="store_true", + "-l", "--list", + action="store_true", help="Print available test suites" ) parser.add_argument( - "-t", "--try-cmd", metavar="COMMAND", + "-t", "--try", + metavar="COMMAND", + dest='try_cmd', help=textwrap.dedent("""\ Run a custom command like this test would (the only environment variable passed to your executable are TERM and PATH) """) ) parser.add_argument( - "-k", "--check-leaks", action="store_true", + "-k", "--check-leaks", + action="store_true", help="Run valgrind on tests (disable usual comparison with bash)" ) parser.add_argument( - "-r", "--range", nargs=2, type=int, metavar=("BEGIN", "END"), + "-r", "--range", + nargs=2, + type=int, + metavar=("BEGIN", "END"), help="Range of test index to run (imply --show-index)" ) parser.add_argument( - "--show-range", action="store_true", + "--show-range", + action="store_true", help="Show test index (useful with --range)" ) parser.add_argument( - "-x", "--exit-first", action="store_true", + "-x", "--exit-first", + action="store_true", help="Exit on first fail" ) parser.add_argument( - "-v", "--verbose", action="count", - help="Increase verbosity level (e.g -vv == 2)" - ) - parser.add_argument( - "-b", "--bonus", action="store_true", - help="Enable bonus tests" - ) - parser.add_argument( - "-n", "--no-bonus", action="store_true", - help="Disable bonus tests" - ) - parser.add_argument( - "-m", "--make", action="store_true", + "-m", "--make", + action="store_true", help="Make minishell and exit" ) parser.add_argument( - "-g", "--pager", action="store_true", + "-g", "--pager", + action="store_true", help="After running the test, display the result in a pager of your choice" ) parser.add_argument( - "suites", nargs='*', metavar="suite", + "suites", + nargs='*', + metavar="SUITE", help=textwrap.dedent("""\ Test suites/group to run. It tries to be smart and autocomplete the suite name (e.g ./run int -> ./run preprocess/interpolation) """) ) - tmp = parser.parse_args() - if tmp.verbose is None: - tmp.verbose = 1 - return tmp + return parser.parse_args() -- cgit