Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
24123:eb2d41c6ec37 | 24124:042d95beeee8 |
---|---|
1138 C sub2/.hgsubstate | 1138 C sub2/.hgsubstate |
1139 C sub2/sub21/21 | 1139 C sub2/sub21/21 |
1140 C sub3/3 | 1140 C sub3/3 |
1141 | 1141 |
1142 $ cd .. | 1142 $ cd .. |
1143 | |
1144 Test synopsis and docstring extending | |
1145 | |
1146 $ hg init exthelp | |
1147 $ cat > exthelp.py <<EOF | |
1148 > from mercurial import commands, extensions | |
1149 > def exbookmarks(orig, *args, **opts): | |
1150 > return orig(*args, **opts) | |
1151 > def uisetup(ui): | |
1152 > synopsis = ' GREPME [--foo] [-x]' | |
1153 > docstring = ''' | |
1154 > GREPME make sure that this is in the help! | |
1155 > ''' | |
1156 > extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks, | |
1157 > synopsis, docstring) | |
1158 > EOF | |
1159 $ abspath=`pwd`/exthelp.py | |
1160 $ echo '[extensions]' >> $HGRCPATH | |
1161 $ echo "exthelp = $abspath" >> $HGRCPATH | |
1162 $ cd exthelp | |
1163 $ hg help bookmarks | grep GREPME | |
1164 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x] | |
1165 GREPME make sure that this is in the help! | |
1166 |