fix: don't skip args if non run command using run

This commit is contained in:
Daylin Morgan 2023-09-27 16:06:22 -05:00
parent 7286e90a36
commit d71542f5d2
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F

View file

@ -2142,12 +2142,13 @@ class Cli:
cmd, cmd,
parents=[self.parsers.get(k) for k in self.cmd_arg_group_map[cmd]], parents=[self.parsers.get(k) for k in self.cmd_arg_group_map[cmd]],
) )
if "--" in sys.argv: if "--" in sys.argv:
i = sys.argv.index("--") i = sys.argv.index("--")
args = self.parser.parse_args(sys.argv[1:i]) args = self.parser.parse_args(sys.argv[1:i])
args.rest = sys.argv[i + 1 :] args.rest = sys.argv[i + 1 :]
elif flag := list({"-s", "--script"} & set(sys.argv)): elif {"r", "run"} & set(sys.argv[1:2]) and (
flag := list({"-s", "--script"} & set(sys.argv))
):
i = sys.argv.index(flag[0]) i = sys.argv.index(flag[0])
args = self.parser.parse_args(sys.argv[1 : i + 2]) args = self.parser.parse_args(sys.argv[1 : i + 2])
args.rest = sys.argv[i + 2 :] args.rest = sys.argv[i + 2 :]