pywikibot.handle_args() can be used to handle global options within scripts like
options = {}
local_args = pywikibot.handle_args()
for arg in local_args;
arg, _, value = arg.partition(':')
if not arg.startswith('-'):
continue
option[arg] = valuebut global options can changes and private options can be hidden by such implementation. Vice versa if the local optionas are handled first, the global options could be discarded.
Problen:
The problem is that global options can be changed or expanded at any time. There is no way to deprecate renamed options or warn for new ones.
Solution:
The prefered way is to use global options throught the pwb wrapper script as descibed there:https://doc.wikimedia.org/pywikibot/master/utilities/scripts_ref.html#module-pywikibot.scripts.wrapper
python pwb.py <global pwb options> <name_of_script> <local script options>
Using this proposal the pywikibot.handle_args is no longer necessary to be used within the script.
This mehtod should be more documented.