1474 if with_version: |
1474 if with_version: |
1475 version_(ui) |
1475 version_(ui) |
1476 ui.write('\n') |
1476 ui.write('\n') |
1477 |
1477 |
1478 try: |
1478 try: |
1479 aliases, i = cmdutil.findcmd(name, table, False) |
1479 aliases, entry = cmdutil.findcmd(name, table, False) |
1480 except error.AmbiguousCommand, inst: |
1480 except error.AmbiguousCommand, inst: |
1481 # py3k fix: except vars can't be used outside the scope of the |
1481 # py3k fix: except vars can't be used outside the scope of the |
1482 # except block, nor can be used inside a lambda. python issue4617 |
1482 # except block, nor can be used inside a lambda. python issue4617 |
1483 prefix = inst.args[0] |
1483 prefix = inst.args[0] |
1484 select = lambda c: c.lstrip('^').startswith(prefix) |
1484 select = lambda c: c.lstrip('^').startswith(prefix) |
1485 helplist(_('list of commands:\n\n'), select) |
1485 helplist(_('list of commands:\n\n'), select) |
1486 return |
1486 return |
1487 |
1487 |
1488 # synopsis |
1488 # synopsis |
1489 if len(i) > 2: |
1489 if len(entry) > 2: |
1490 if i[2].startswith('hg'): |
1490 if entry[2].startswith('hg'): |
1491 ui.write("%s\n" % i[2]) |
1491 ui.write("%s\n" % entry[2]) |
1492 else: |
1492 else: |
1493 ui.write('hg %s %s\n' % (aliases[0], i[2])) |
1493 ui.write('hg %s %s\n' % (aliases[0], entry[2])) |
1494 else: |
1494 else: |
1495 ui.write('hg %s\n' % aliases[0]) |
1495 ui.write('hg %s\n' % aliases[0]) |
1496 |
1496 |
1497 # aliases |
1497 # aliases |
1498 if not ui.quiet and len(aliases) > 1: |
1498 if not ui.quiet and len(aliases) > 1: |
1499 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
1499 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
1500 |
1500 |
1501 # description |
1501 # description |
1502 doc = gettext(i[0].__doc__) |
1502 doc = gettext(entry[0].__doc__) |
1503 if not doc: |
1503 if not doc: |
1504 doc = _("(no help text available)") |
1504 doc = _("(no help text available)") |
1505 if ui.quiet: |
1505 if ui.quiet: |
1506 doc = doc.splitlines()[0] |
1506 doc = doc.splitlines()[0] |
1507 ui.write("\n%s\n" % minirst.format(doc, textwidth)) |
1507 ui.write("\n%s\n" % minirst.format(doc, textwidth)) |
1508 |
1508 |
1509 if not ui.quiet: |
1509 if not ui.quiet: |
1510 # options |
1510 # options |
1511 if i[1]: |
1511 if entry[1]: |
1512 option_lists.append((_("options:\n"), i[1])) |
1512 option_lists.append((_("options:\n"), entry[1])) |
1513 |
1513 |
1514 addglobalopts(False) |
1514 addglobalopts(False) |
1515 |
1515 |
1516 def helplist(header, select=None): |
1516 def helplist(header, select=None): |
1517 h = {} |
1517 h = {} |