Mercurial > hg-stable
diff tests/test-extension.t @ 24124:042d95beeee8
extensions: allow extending command synopsis and docstring
Mercurial uses a synopsis string and the docstring of a command for the
command's help output. Today there is no way for an extension that adds
functionality to a command to extend either of these help strings.
This patch enables appending to both the doctring and the synopsis, and adds
a test for this functionality. Example usage is shown in the test and is also
described in the docstring of extensions.wrapcommand().
author | Ryan McElroy <rm@fb.com> |
---|---|
date | Mon, 09 Feb 2015 11:02:45 -0800 |
parents | b2d8f3685b06 |
children | 31e9f66863f3 |
line wrap: on
line diff
--- a/tests/test-extension.t Wed Jan 21 17:11:37 2015 -0500 +++ b/tests/test-extension.t Mon Feb 09 11:02:45 2015 -0800 @@ -1140,3 +1140,27 @@ C sub3/3 $ cd .. + +Test synopsis and docstring extending + + $ hg init exthelp + $ cat > exthelp.py <<EOF + > from mercurial import commands, extensions + > def exbookmarks(orig, *args, **opts): + > return orig(*args, **opts) + > def uisetup(ui): + > synopsis = ' GREPME [--foo] [-x]' + > docstring = ''' + > GREPME make sure that this is in the help! + > ''' + > extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks, + > synopsis, docstring) + > EOF + $ abspath=`pwd`/exthelp.py + $ echo '[extensions]' >> $HGRCPATH + $ echo "exthelp = $abspath" >> $HGRCPATH + $ cd exthelp + $ hg help bookmarks | grep GREPME + hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x] + GREPME make sure that this is in the help! +