Show More
@@ -20,6 +20,7 b' from . import (' | |||
|
20 | 20 | encoding, |
|
21 | 21 | error, |
|
22 | 22 | extensions, |
|
23 | fancyopts, | |
|
23 | 24 | filemerge, |
|
24 | 25 | fileset, |
|
25 | 26 | minirst, |
@@ -84,7 +85,10 b' def optrst(header, options, verbose):' | |||
|
84 | 85 | if shortopt: |
|
85 | 86 | so = '-' + shortopt |
|
86 | 87 | lo = '--' + longopt |
|
87 | if default: | |
|
88 | ||
|
89 | if isinstance(default, fancyopts.customopt): | |
|
90 | default = default.defaultvalue | |
|
91 | if default and not callable(default): | |
|
88 | 92 | # default is of unknown type, and in Python 2 we abused |
|
89 | 93 | # the %s-shows-repr property to handle integers etc. To |
|
90 | 94 | # match that behavior on Python 3, we do str(default) and |
@@ -716,15 +716,23 b' this is a section and erroring out weird' | |||
|
716 | 716 | |
|
717 | 717 | $ cat > helpext.py <<EOF |
|
718 | 718 | > import os |
|
719 | > from mercurial import commands, registrar | |
|
719 | > from mercurial import commands, fancyopts, registrar | |
|
720 | 720 | > |
|
721 | > def func(arg): | |
|
722 | > return '%sfoo' % arg | |
|
723 | > class customopt(fancyopts.customopt): | |
|
724 | > def newstate(self, oldstate, newparam, abort): | |
|
725 | > return '%sbar' % oldstate | |
|
721 | 726 | > cmdtable = {} |
|
722 | 727 | > command = registrar.command(cmdtable) |
|
723 | 728 | > |
|
724 | 729 |
> @command(b |
|
725 |
> [(b |
|
|
730 | > [(b'', b'longdesc', 3, b'x'*67), | |
|
726 | 731 | > (b'n', b'', None, b'normal desc'), |
|
727 |
> (b'', b'newline', b'', b'line1\nline2') |
|
|
732 | > (b'', b'newline', b'', b'line1\nline2'), | |
|
733 | > (b'', b'callableopt', func, b'adds foo'), | |
|
734 | > (b'', b'customopt', customopt(''), b'adds bar'), | |
|
735 | > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')], | |
|
728 | 736 | > b'hg nohelp', |
|
729 | 737 | > norepo=True) |
|
730 | 738 | > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')]) |
@@ -786,10 +794,14 b' Test command with no help text' | |||
|
786 | 794 | |
|
787 | 795 | options: |
|
788 | 796 | |
|
789 | --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
|
790 |
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|
|
791 | -n -- normal desc | |
|
792 | --newline VALUE line1 line2 | |
|
797 | --longdesc VALUE | |
|
798 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
|
799 | xxxxxxxxxxxxxxxxxxxxxxx (default: 3) | |
|
800 | -n -- normal desc | |
|
801 | --newline VALUE line1 line2 | |
|
802 | --callableopt VALUE adds foo | |
|
803 | --customopt VALUE adds bar | |
|
804 | --customopt-withdefault VALUE adds bar (default: foo) | |
|
793 | 805 | |
|
794 | 806 | (some details hidden, use --verbose to show complete help) |
|
795 | 807 |
General Comments 0
You need to be logged in to leave comments.
Login now