Ori.livneh has submitted this change and it was merged.
Change subject: mwgrep: Improve in-line help
......................................................................
mwgrep: Improve in-line help
Change-Id: I21c17d61e0de7ef7eaaf5e8b149224681c1528ee
---
M files/misc/scripts/mwgrep
1 file changed, 46 insertions(+), 10 deletions(-)
Approvals:
Ori.livneh: Verified; Looks good to me, approved
diff --git a/files/misc/scripts/mwgrep b/files/misc/scripts/mwgrep
index 5b6d8e5..ffe5ce1 100755
--- a/files/misc/scripts/mwgrep
+++ b/files/misc/scripts/mwgrep
@@ -1,10 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
- mwgrep
- ~~~~~~
- Grep for CSS or JS code in wiki pages
- Usage: mwgrep [--user] [--max-results N] [--timeout N] TERM
+ usage: mwgrep [-h] [--max-results N] [--timeout N] [--user] term
+
+ Grep for CSS and JS code fragments in MediaWiki wiki pages
+
+ positional arguments:
+ term text to search for
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --max-results N show at most this many results (default: 100)
+ --timeout N abort search after this many seconds (default: 30)
+ --user search NS_USER rather than NS_MEDIAWIKI
+
+ mwgrep will grep the MediaWiki namespace across Wikimedia wikis. specify
+ --user to search the user namespace instead.
"""
import argparse
@@ -18,13 +29,38 @@
NS_MEDIAWIKI = 8
NS_USER = 2
-ap = argparse.ArgumentParser(description='Grep for CSS/JS in wiki pages')
+ap = argparse.ArgumentParser(
+ prog='mwgrep',
+ description='Grep for CSS and JS code fragments in MediaWiki wiki pages',
+ epilog='mwgrep will grep the MediaWiki namespace across Wikimedia wikis. '
+ 'specify --user to search the user namespace instead.'
+)
ap.add_argument('term', help='text to search for')
-ap.add_argument('--max-results', type=int, default=100)
-ap.add_argument('--timeout', type=int, default=30)
-ap.add_argument('--user', action='store_const', const=NS_USER,
- default=NS_MEDIAWIKI, dest='ns',
- help='search NS_USER rather than NS_MEDIAWIKI')
+
+ap.add_argument(
+ '--max-results',
+ metavar='N',
+ type=int, default=100,
+ help='show at most this many results (default: 100)'
+)
+
+ap.add_argument(
+ '--timeout',
+ metavar='N',
+ type=int,
+ default=30,
+ help='abort search after this many seconds (default: 30)'
+)
+
+ap.add_argument(
+ '--user',
+ action='store_const',
+ const=NS_USER,
+ default=NS_MEDIAWIKI,
+ dest='ns',
+ help='search NS_USER rather than NS_MEDIAWIKI'
+)
+
args = ap.parse_args()
filters = [
--
To view, visit https://gerrit.wikimedia.org/r/118671
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I21c17d61e0de7ef7eaaf5e8b149224681c1528ee
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits