add debugcommands command: an easy to parse command + option index
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Mon, 23 Mar 2009 13:43:48 +0100
changeset 7880 7ca2be800804
parent 7879 5c4026a289a4
child 7881 3ac7114c2555
add debugcommands command: an easy to parse command + option index
mercurial/commands.py
tests/test-debugcomplete
tests/test-debugcomplete.out
--- a/mercurial/commands.py	Mon Mar 23 10:41:42 2009 +0100
+++ b/mercurial/commands.py	Mon Mar 23 13:43:48 2009 +0100
@@ -683,6 +683,12 @@
     a = r.ancestor(lookup(rev1), lookup(rev2))
     ui.write("%d:%s\n" % (r.rev(a), hex(a)))
 
+def debugcommands(ui, cmd='', *args):
+    for cmd, vals in util.sort(table.iteritems()):
+        cmd = cmd.split('|')[0].strip('^')
+        opts = ', '.join([i[1] for i in vals[1]])
+        ui.write('%s: %s\n' % (cmd, opts))
+
 def debugcomplete(ui, cmd='', **opts):
     """returns the completion list associated with the given command"""
 
@@ -3134,6 +3140,7 @@
          _('[OPTION]... [SOURCE]... DEST')),
     "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
     "debugcheckstate": (debugcheckstate, []),
+    "debugcommands": (debugcommands, [], _('[COMMAND]')),
     "debugcomplete":
         (debugcomplete,
          [('o', 'options', None, _('show the command options'))],
@@ -3416,6 +3423,6 @@
     "version": (version_, []),
 }
 
-norepo = ("clone init version help debugcomplete debugdata"
+norepo = ("clone init version help debugcommands debugcomplete debugdata"
           " debugindex debugindexdot debugdate debuginstall debugfsinfo")
 optionalrepo = ("identify paths serve showconfig debugancestor")
--- a/tests/test-debugcomplete	Mon Mar 23 10:41:42 2009 +0100
+++ b/tests/test-debugcomplete	Mon Mar 23 13:43:48 2009 +0100
@@ -36,4 +36,8 @@
 echo '% Show an error if we use --options with an ambiguous abbreviation'
 hg debugcomplete --options s
 
+echo
+echo '% Show all commands + options'
+hg debugcommands
+
 exit 0
--- a/tests/test-debugcomplete.out	Mon Mar 23 10:41:42 2009 +0100
+++ b/tests/test-debugcomplete.out	Mon Mar 23 13:43:48 2009 +0100
@@ -60,6 +60,7 @@
 % Show debug commands if there are no other candidates
 debugancestor
 debugcheckstate
+debugcommands
 debugcomplete
 debugconfig
 debugdata
@@ -160,3 +161,69 @@
 % Show an error if we use --options with an ambiguous abbreviation
 hg: command 's' is ambiguous:
     serve showconfig status
+
+% Show all commands + options
+add: include, exclude, dry-run
+annotate: rev, follow, text, user, date, number, changeset, line-number, include, exclude
+clone: noupdate, rev, pull, uncompressed, ssh, remotecmd
+commit: addremove, close-branch, include, exclude, message, logfile, date, user
+diff: rev, change, text, git, nodates, show-function, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, include, exclude
+export: output, switch-parent, text, git, nodates
+init: ssh, remotecmd
+log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, prune, patch, git, limit, no-merges, style, template, include, exclude
+merge: force, rev
+parents: rev, style, template
+pull: update, force, rev, ssh, remotecmd
+push: force, rev, ssh, remotecmd
+remove: after, force, include, exclude
+serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, webdir-conf, pid-file, stdio, templates, style, ipv6, certificate
+status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, include, exclude
+update: clean, date, rev
+addremove: similarity, include, exclude, dry-run
+archive: no-decode, prefix, rev, type, include, exclude
+backout: merge, parent, rev, include, exclude, message, logfile, date, user
+bisect: reset, good, bad, skip, command, noupdate
+branch: force, clean
+branches: active
+bundle: force, rev, base, all, type, ssh, remotecmd
+cat: output, rev, decode, include, exclude
+copy: after, force, include, exclude, dry-run
+debugancestor: 
+debugcheckstate: 
+debugcommands: 
+debugcomplete: options
+debugdata: 
+debugdate: extended
+debugfsinfo: 
+debugindex: 
+debugindexdot: 
+debuginstall: 
+debugrawcommit: parent, files, message, logfile, date, user
+debugrebuildstate: rev
+debugrename: rev
+debugsetparents: 
+debugstate: nodates
+debugwalk: include, exclude
+grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
+heads: rev, active, style, template
+help: 
+identify: rev, num, id, branch, tags
+import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
+incoming: force, newest-first, bundle, rev, patch, git, limit, no-merges, style, template, ssh, remotecmd
+locate: rev, print0, fullpath, include, exclude
+manifest: rev
+outgoing: force, rev, newest-first, patch, git, limit, no-merges, style, template, ssh, remotecmd
+paths: 
+recover: 
+rename: after, force, include, exclude, dry-run
+resolve: all, list, mark, unmark, include, exclude
+revert: all, date, rev, no-backup, include, exclude, dry-run
+rollback: 
+root: 
+showconfig: untrusted
+tag: force, local, rev, remove, message, date, user
+tags: 
+tip: patch, git, style, template
+unbundle: update
+verify: 
+version: