From e625b3b6c2e1dece47b2d5fd9716c75cf8589e73 Mon Sep 17 00:00:00 2001 From: JTignor-Raltron <114696222+JTignor-Raltron@users.noreply.github.com> Date: Fri, 26 Jan 2024 09:30:39 -0500 Subject: [PATCH] Fix commands with arguments that start with "-" Parameters that start with "-" are interpreted as a new argument. argparse.REMAINDER forces it to interpret all everything left in the command as a list of strings instead of new arguments. Fixes issue #177 --- menuinst/_legacy/cwp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menuinst/_legacy/cwp.py b/menuinst/_legacy/cwp.py index df8086b3..f8a3c388 100644 --- a/menuinst/_legacy/cwp.py +++ b/menuinst/_legacy/cwp.py @@ -18,7 +18,7 @@ def main(): "--no-console", action="store_true", help="Create subprocess with CREATE_NO_WINDOW flag." ) parser.add_argument("prefix", help="Prefix to be 'activated' before calling `args`.") - parser.add_argument("args", nargs="*", help="Command (and arguments) to be executed.") + parser.add_argument("args", nargs=argparse.REMAINDER, help="Command (and arguments) to be executed.") parsed_args = parser.parse_args() no_console = parsed_args.no_console