Bug 1386561 - Add mach-commands command to mach, r=franziskus
authorMartin Thomson <martin.thomson@gmail.com>
Wed, 02 Aug 2017 15:54:00 +1000
changeset 13499 cf401853d274aa9684310824e81db9fadbcf4d75
parent 13498 bb2e1fd1d7a9bbd9b33116713e20b8de97958300
child 13500 2a84e61b588e7ab2b355705e2d71505d8904d043
push id2301
push usermartin.thomson@gmail.com
push dateWed, 02 Aug 2017 09:29:41 +0000
reviewersfranziskus
bugs1386561
Bug 1386561 - Add mach-commands command to mach, r=franziskus
mach
--- a/mach
+++ b/mach
@@ -117,16 +117,23 @@ class testAction(argparse.Action):
         }
         command = cwd + "/tests/all.sh"
         subprocess.check_call(command, env=env)
 
     def __call__(self, parser, args, values, option_string=None):
         self.runTest(values)
 
 
+class commandsAction(argparse.Action):
+    commands = []
+    def __call__(self, parser, args, values, option_string=None):
+        for c in commandsAction.commands:
+            print(c)
+
+
 def parse_arguments():
     parser = argparse.ArgumentParser(
         description='NSS helper script. ' +
         'Make sure to separate sub-command arguments with --.')
     subparsers = parser.add_subparsers()
 
     parser_build = subparsers.add_parser(
         'build', help='All arguments are passed to build.sh')
@@ -146,16 +153,26 @@ def parse_arguments():
         'tests', help='Run tests through tests/all.sh.')
     tests = [
         "cipher", "lowhash", "chains", "cert", "dbtests", "tools", "fips",
         "sdr", "crmf", "smime", "ssl", "ocsp", "merge", "pkits", "ec",
         "gtests", "ssl_gtests"
     ]
     parser_test.add_argument(
         'test', choices=tests, help="Available tests", action=testAction)
+
+    parser_commands = subparsers.add_parser(
+        'mach-commands',
+        help="list commands")
+    parser_commands.add_argument(
+        'mach-commands',
+        nargs='*',
+        action=commandsAction)
+
+    commandsAction.commands = [c for c in subparsers.choices]
     return parser.parse_args()
 
 
 def main():
     parse_arguments()
 
 
 if __name__ == '__main__':