Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/help.py @ 22116:161085f87b95
help: roll option list header into option formatter
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 12 Aug 2014 03:53:33 -0500 |
parents | 8465625f7364 |
children | c1d93edcf004 |
comparison
equal
deleted
inserted
replaced
22115:8465625f7364 | 22116:161085f87b95 |
---|---|
29 _('enabled extensions:'), extensions.enabled(), showdeprecated=True)) | 29 _('enabled extensions:'), extensions.enabled(), showdeprecated=True)) |
30 rst.extend(listexts(_('disabled extensions:'), extensions.disabled())) | 30 rst.extend(listexts(_('disabled extensions:'), extensions.disabled())) |
31 doc = ''.join(rst) | 31 doc = ''.join(rst) |
32 return doc | 32 return doc |
33 | 33 |
34 def optrst(options, verbose): | 34 def optrst(header, options, verbose): |
35 data = [] | 35 data = [] |
36 multioccur = False | 36 multioccur = False |
37 for option in options: | 37 for option in options: |
38 if len(option) == 5: | 38 if len(option) == 5: |
39 shortopt, longopt, default, desc, optlabel = option | 39 shortopt, longopt, default, desc, optlabel = option |
57 elif (default is not None) and not isinstance(default, bool): | 57 elif (default is not None) and not isinstance(default, bool): |
58 lo += " %s" % optlabel | 58 lo += " %s" % optlabel |
59 | 59 |
60 data.append((so, lo, desc)) | 60 data.append((so, lo, desc)) |
61 | 61 |
62 rst = minirst.maketable(data, 1) | 62 rst = ['\n%s:\n\n' % header] |
63 rst.extend(minirst.maketable(data, 1)) | |
63 | 64 |
64 if multioccur: | 65 if multioccur: |
65 rst.append(_("\n[+] marked option can be specified multiple times\n")) | 66 rst.append(_("\n[+] marked option can be specified multiple times\n")) |
66 | 67 |
67 return ''.join(rst) | 68 return ''.join(rst) |
282 except KeyError: | 283 except KeyError: |
283 pass | 284 pass |
284 | 285 |
285 # options | 286 # options |
286 if not ui.quiet and entry[1]: | 287 if not ui.quiet and entry[1]: |
287 rst.append('\n%s\n\n' % _("options:")) | 288 rst.append(optrst(_("options"), entry[1], ui.verbose)) |
288 rst.append(optrst(entry[1], ui.verbose)) | |
289 | 289 |
290 if ui.verbose: | 290 if ui.verbose: |
291 rst.append('\n%s\n\n' % _("global options:")) | 291 rst.append(optrst(_("global options"), |
292 rst.append(optrst(commands.globalopts, ui.verbose)) | 292 commands.globalopts, ui.verbose)) |
293 | 293 |
294 if not ui.verbose: | 294 if not ui.verbose: |
295 if not full: | 295 if not full: |
296 rst.append(_('\n(use "hg %s -h" to show more help)\n') | 296 rst.append(_('\n(use "hg %s -h" to show more help)\n') |
297 % name) | 297 % name) |
364 rst.append(" :%s: %s\n" % (t, desc)) | 364 rst.append(" :%s: %s\n" % (t, desc)) |
365 | 365 |
366 if ui.quiet: | 366 if ui.quiet: |
367 pass | 367 pass |
368 elif ui.verbose: | 368 elif ui.verbose: |
369 rst.append(_("\nglobal options:\n")) | 369 rst.append('\n%s\n' % optrst(_("global options"), |
370 rst.append('\n%s\n' % optrst(commands.globalopts, ui.verbose)) | 370 commands.globalopts, ui.verbose)) |
371 if name == 'shortlist': | 371 if name == 'shortlist': |
372 rst.append(_('\nuse "hg help" for the full list ' | 372 rst.append(_('\nuse "hg help" for the full list ' |
373 'of commands\n')) | 373 'of commands\n')) |
374 else: | 374 else: |
375 if name == 'shortlist': | 375 if name == 'shortlist': |