Page MenuHomePhabricator

replicate_wiki doesnt support help or other global command line options
Closed, ResolvedPublic

Description

replicate_wiki does not call handleArgs, and uses argparse without offering something like -help.


Version: core-(2.0)
Severity: major

Details

Reference
bz68664

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:40 AM
bzimport set Reference to bz68664.
bzimport added a subscriber: Unknown Object (????).
jayvdb created this task.Jul 27 2014, 6:28 AM

--help or -h would do:

$ python pwb.py scripts/replicate_wiki.py -h
usage: replicate_wiki.py [-h] [-f FAMILY] [-r] [-o ORIGINAL_WIKI]

[-ns NAMESPACE] [-dns DEST_NAMESPACE]
destination [destination ...]

positional arguments:

destination           destination wiki(s)

optional arguments:

-h, --help            show this help message and exit
-f FAMILY, --family FAMILY
                      wiki family
-r, --replace         actually replace pages (without this option you will
                      only get an overview page)
-o ORIGINAL_WIKI, --original ORIGINAL_WIKI
                      original wiki
-ns NAMESPACE, --namespace NAMESPACE
                      specify namespace
-dns DEST_NAMESPACE, --dest-namespace DEST_NAMESPACE
                      destination namespace (if different)

Note handleArgs has been replaced with handle_args.

--help or -h would do:
$ python pwb.py scripts/replicate_wiki.py -h
usage: replicate_wiki.py [-h] [-f FAMILY] [-r] [-o ORIGINAL_WIKI]

[-ns NAMESPACE] [-dns DEST_NAMESPACE]
destination [destination ...]

positional arguments:

destination           destination wiki(s)

optional arguments:

-h, --help            show this help message and exit
-f FAMILY, --family FAMILY
                      wiki family
-r, --replace         actually replace pages (without this option you will
                      only get an overview page)
-o ORIGINAL_WIKI, --original ORIGINAL_WIKI
                      original wiki
-ns NAMESPACE, --namespace NAMESPACE
                      specify namespace
-dns DEST_NAMESPACE, --dest-namespace DEST_NAMESPACE
                      destination namespace (if different)

--help does emi the above, bit --help/-help should also show the global options which are documented in pywikibot/bot.py showHelp() variable globalHelp

this is tested by tests/script_tests.py - edit that file to see replicate_wiki.py is treated differently because it doesnt emit the standard global help message.

murfel added a subscriber: murfel.Dec 3 2014, 7:22 AM
jayvdb added a comment.Dec 3 2014, 7:44 AM

Noting that this is a claimed CGI task https://www.google-melange.com/gci/task/view/google/gci2014/5790882494152704

Welcome murfel. You can ask questions here (public) or on melange (private) or on IRC (also private; more fluid discussion). Once the first patch is up, discussion often happens in the gerrit system. See https://gerrit.wikimedia.org/r/#/c/176747/ for an example (another CGI task, recently finished)

murfel claimed this task.Dec 3 2014, 11:36 AM

Right now replicate_wiki.py uses argparse to parse local arguments. Once handle_args is added to parse global arguments, should it parse local arguments too? If use combination of both handle_args for global and argparse for local arguments then -h would look like

$ python pwb.py scripts/replicate_wiki.py -h
Introduction … (given by handle_args)
Global arguments …
usage: … (given by argparse)
positional arguments: …
optional arguments: …

XZise added a subscriber: XZise.Dec 3 2014, 11:48 AM

There is a similar script editarticle.py which has been fixed recently see T70617 and https://gerrit.wikimedia.org/r/#/c/176747/.

I'd deactivate --help (it will be supported for all scripts with T76429) via the add_help=False argument. The help is then handled by the handle_args if -help is used.

Change 177216 had a related patch set uploaded (by Murfel):
T70664 Added global options support

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

Patch-For-Review

Change 177216 had a related patch set uploaded (by Murfel):
Added global options support

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

Patch-For-Review

murfel closed this task as Resolved.Dec 6 2014, 4:54 PM
jayvdb set Security to None.
jayvdb removed a subscriber: Unknown Object (????).
jayvdb moved this task from Backlog to pywikibot on the Google-Code-in-2014 board.Dec 7 2014, 2:11 AM