jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/756160 )

Change subject: [IMPR] Simplify redirect.main()
......................................................................

[IMPR] Simplify redirect.main()

- import suggest_help
- combine suggest_help parameters and return once if a message is printed

Change-Id: Ic8ef99e71a3b5619d113202f0ea3990e4efeab24
---
M scripts/redirect.py
1 file changed, 9 insertions(+), 11 deletions(-)

Approvals:
  D3r1ck01: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/redirect.py b/scripts/redirect.py
index ec74455..a282407 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -78,7 +78,8 @@
 import pywikibot.data
 from pywikibot import i18n, pagegenerators, xmlreader
 from pywikibot.backports import Dict, List, Set, Tuple
-from pywikibot.bot import ExistingPageBot, OptionHandler, RedirectPageBot
+from pywikibot.bot import (
+    ExistingPageBot, OptionHandler, RedirectPageBot, suggest_help)
 from pywikibot.exceptions import (
     CircularRedirectError,
     InterwikiRedirectPageError,
@@ -671,6 +672,7 @@
     # redirs)
     action = None
     source = set()
+    unknown = []
     gen_factory = pagegenerators.GeneratorFactory()

     local_args = pywikibot.handle_args(args)
@@ -706,17 +708,13 @@
         elif gen_factory.handle_arg(argument):
             pass
         else:
-            pywikibot.output('Unknown argument: ' + arg)
+            unknown.append(arg)

-    if len(source) > 1:
-        problem = 'You can only use one of {} options.'.format(
-            ' or '.join(source))
-        pywikibot.bot.suggest_help(additional_text=problem,
-                                   missing_action=not action)
-        return
-
-    if not action:
-        pywikibot.bot.suggest_help(missing_action=True)
+    problem = 'You can only use one of {} options.'.format(
+        ' or '.join(source)) if len(source) > 1 else ''
+    if suggest_help(additional_text=problem,
+                    unknown_parameters=unknown,
+                    missing_action=not action):
         return

     gen = None

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/756160
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ic8ef99e71a3b5619d113202f0ea3990e4efeab24
Gerrit-Change-Number: 756160
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to