qvm-template: allow global arguments after action name

It's convenient to use for example
`qvm-template list --enablerepo=*-testing`
Previously, _some_ options needed to be before action name.
This commit is contained in:
Marek Marczykowski-Górecki 2021-02-04 17:04:48 +01:00
parent e0063d8808
commit 10bea1b77e
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -1414,7 +1414,9 @@ def main(args: typing.Optional[typing.Sequence[str]] = None,
:return: Return code of the application :return: Return code of the application
""" """
p_args = parser.parse_args(args) # do two passes to allow global options after command name too
p_args, args = parser.parse_known_args(args)
p_args = parser.parse_args(args, p_args)
if not p_args.command: if not p_args.command:
parser.error('A command needs to be specified.') parser.error('A command needs to be specified.')