File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,10 @@ def _get_help_record(opt):
4444 def _write_opts (opts ):
4545 rv , _ = click .formatting .join_options (opts )
4646 if not opt .is_flag and not opt .count :
47- rv += ' <{}>' .format (opt .name )
47+ name = opt .name
48+ if opt .metavar :
49+ name = opt .metavar .lstrip ('<[{($' ).rstrip ('>]})$' )
50+ rv += ' <{}>' .format (name )
4851 return rv
4952
5053 rv = [_write_opts (opt .opts )]
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ def test_basic_parameters(self):
4646
4747 @click .command ()
4848 @click .option ('--param' , envvar = 'PARAM' , help = 'A sample option' )
49+ @click .option ('--another' , metavar = '[FOO]' , help = 'Another option' )
4950 @click .option (
5051 '--choice' ,
5152 help = 'A sample option with choices' ,
@@ -75,6 +76,10 @@ def foobar(bar):
7576
7677 A sample option
7778
79+ .. option:: --another <FOO>
80+
81+ Another option
82+
7883 .. option:: --choice <choice>
7984
8085 A sample option with choices
You can’t perform that action at this time.
0 commit comments