Ladsgroup has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/156089

Change subject: [WIP] use standard arguments
......................................................................

[WIP] use standard arguments

Using argparse, needs tons and tons of work

Change-Id: I195dbef458ce41434a67deb02180031230c6fbbc
---
M pywikibot/bot.py
1 file changed, 37 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/89/156089/1

diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 2417922..8c722c7 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -23,6 +23,7 @@
 import re
 import json
 import datetime
+import argparse
 
 _logger = "bot"
 
@@ -560,11 +561,6 @@
     args may be passed as an argument, thereby overriding sys.argv
 
     """
-    # get commandline arguments if necessary
-    if not args:
-        # it's the version in pywikibot.__init__ that is changed by scripts,
-        # not the one in pywikibot.bot.
-        args = pywikibot.argvu[1:]
     # get the name of the module calling this function. This is
     # required because the -help option loads the module's docstring and 
because
     # the module name will be used for the filename of the log.
@@ -574,6 +570,42 @@
     nonGlobalArgs = []
     username = None
     do_help = False
+    parser = argparse.ArgumentParser(description='Something', prog=moduleName)
+    parser.add_argument(
+        '-f', '--family', nargs='?', dest='config.family',
+        default=config.family,
+        help='sum the integers (default: find the max)')
+    parser.add_argument(
+        '-l', '--lang', nargs='?', dest='config.mylang',
+        help='sum the integers (default: find the max)',
+        default=config.mylang)
+    parser.add_argument(
+        '-u', '--user', nargs='?', dest='username',
+        help='sum the integers (default: find the max)',
+        default=username)
+    parser.add_argument(
+        '-pt', '--putthrottle', nargs='?',
+        dest='config.put_throttle',
+        default=config.put_throttle,
+        help='sum the integers (default: find the max)')
+    parser.add_argument(
+        '--log', nargs='?', dest='config.family',
+        help='sum the integers (default: find the max)')
+    parser.add_argument(
+        '--nolog', nargs='?', dest='config.family',
+        help='sum the integers (default: find the max)')
+    parser.add_argument(
+        '-cc', '--cosmeticchanges', action='store_true',
+        dest='config.cosmetic_changes',
+        default=config.cosmetic_changes,
+        help='sum the integers (default: find the max)')
+    # get commandline arguments if necessary
+    if not args:
+        # it's the version in pywikibot.__init__ that is changed by scripts,
+        # not the one in pywikibot.bot.
+        args = pywikibot.argvu[1:]
+    #I should use something like namespace=something but I don't know how :(
+    print parser.parse_args(args)
     for arg in args:
         if arg == '-help':
             do_help = True

-- 
To view, visit https://gerrit.wikimedia.org/r/156089
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I195dbef458ce41434a67deb02180031230c6fbbc
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgr...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to