[cli] Allow -y/--yes to be specified as part of the subcommand arguments

This commit is contained in:
derrod 2020-11-21 14:30:30 +01:00
parent 1598844bc6
commit 22b7db7a29

View file

@ -1294,10 +1294,10 @@ def main():
logging.getLogger('requests').setLevel(logging.WARNING)
logging.getLogger('urllib3').setLevel(logging.WARNING)
# -y having to be specified before the subcommand is a little counter-intuitive
# For now show a warning if a user is misusing that flag
# if --yes is used as part of the subparsers arguments manually set the flag in the main parser.
if '-y' in extra or '--yes' in extra:
logger.warning('-y/--yes flag needs to be specified *before* the command name')
args.yes = True
extra = [i for i in extra if i not in ('--yes', '-y')]
# technically args.func() with setdefaults could work (see docs on subparsers)
# but that would require all funcs to accept args and extra...