Bug 846409 - Add |mach mach-debug-commands|; r=jhammel
authorGregory Szorc <gps@mozilla.com>
Mon, 04 Mar 2013 10:18:48 -0800
changeset 123619 61568b93a60155d15191245309d89349940884df
parent 123618 f99a075a5bce157bf2d000533153e1b109823222
child 123620 bf88a316cf18242cecd3182bcdfce2e09bbb851c
push idunknown
push userunknown
push dateunknown
reviewersjhammel
bugs846409
milestone22.0a1
Bug 846409 - Add |mach mach-debug-commands|; r=jhammel DONTBUILD (NPOTB)
build/mach_bootstrap.py
python/mach/mach/commands/commandinfo.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -26,16 +26,17 @@ SEARCH_PATHS = [
     'testing/mozbase/mozfile',
     'testing/mozbase/mozinfo',
 ]
 
 # Individual files providing mach commands.
 MACH_MODULES = [
     'addon-sdk/mach_commands.py',
     'layout/tools/reftest/mach_commands.py',
+    'python/mach/mach/commands/commandinfo.py',
     'python/mozboot/mozboot/mach_commands.py',
     'python/mozbuild/mozbuild/config.py',
     'python/mozbuild/mozbuild/mach_commands.py',
     'python/mozbuild/mozbuild/frontend/mach_commands.py',
     'testing/mochitest/mach_commands.py',
     'testing/xpcshell/mach_commands.py',
 ]
 
new file mode 100644
--- /dev/null
+++ b/python/mach/mach/commands/commandinfo.py
@@ -0,0 +1,35 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, # You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function, unicode_literals
+
+from mach.decorators import (
+    CommandProvider,
+    Command,
+)
+
+
+@CommandProvider
+class BuiltinCommands(object):
+    def __init__(self, context):
+        self.context = context
+
+    @Command('mach-debug-commands', help='Show info about available mach commands.')
+    def commands(self):
+        import inspect
+
+        handlers = self.context.commands.command_handlers
+        for command in sorted(handlers.keys()):
+            handler = handlers[command]
+            cls = handler.cls
+            method = getattr(cls, getattr(handler, 'method'))
+
+            print(command)
+            print('=' * len(command))
+            print('')
+            print('File: %s' % inspect.getsourcefile(method))
+            print('Class: %s' % cls.__name__)
+            print('Method: %s' % handler.method)
+            print('')
+