Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 30514:158b41842fd2
debugcommands: move 'debugcomplete' in the new module
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 17 Aug 2016 20:41:05 -0700 |
parents | c3bdc27121d1 |
children | 625ccc95fa96 |
comparison
equal
deleted
inserted
replaced
30513:c3bdc27121d1 | 30514:158b41842fd2 |
---|---|
327 """list all available commands and options""" | 327 """list all available commands and options""" |
328 for cmd, vals in sorted(commands.table.iteritems()): | 328 for cmd, vals in sorted(commands.table.iteritems()): |
329 cmd = cmd.split('|')[0].strip('^') | 329 cmd = cmd.split('|')[0].strip('^') |
330 opts = ', '.join([i[1] for i in vals[1]]) | 330 opts = ', '.join([i[1] for i in vals[1]]) |
331 ui.write('%s: %s\n' % (cmd, opts)) | 331 ui.write('%s: %s\n' % (cmd, opts)) |
332 | |
333 @command('debugcomplete', | |
334 [('o', 'options', None, _('show the command options'))], | |
335 _('[-o] CMD'), | |
336 norepo=True) | |
337 def debugcomplete(ui, cmd='', **opts): | |
338 """returns the completion list associated with the given command""" | |
339 | |
340 if opts.get('options'): | |
341 options = [] | |
342 otables = [commands.globalopts] | |
343 if cmd: | |
344 aliases, entry = cmdutil.findcmd(cmd, commands.table, False) | |
345 otables.append(entry[1]) | |
346 for t in otables: | |
347 for o in t: | |
348 if "(DEPRECATED)" in o[3]: | |
349 continue | |
350 if o[0]: | |
351 options.append('-%s' % o[0]) | |
352 options.append('--%s' % o[1]) | |
353 ui.write("%s\n" % "\n".join(options)) | |
354 return | |
355 | |
356 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, commands.table) | |
357 if ui.verbose: | |
358 cmdlist = [' '.join(c[0]) for c in cmdlist.values()] | |
359 ui.write("%s\n" % "\n".join(sorted(cmdlist))) |