diff --git a/build/mach_bootstrap.py b/build/mach_bootstrap.py index 7b0020787317..4d26018f3bed 100644 --- a/build/mach_bootstrap.py +++ b/build/mach_bootstrap.py @@ -108,6 +108,11 @@ CATEGORIES = { 'short': 'Potpourri', 'long': 'Potent potables and assorted snacks.', 'priority': 10, + }, + 'disabled': { + 'short': 'Disabled', + 'long': 'These commands are unavailable for your current context, run "mach " to see why.', + 'priority': 0, } } diff --git a/python/mach/mach/dispatcher.py b/python/mach/mach/dispatcher.py index e3fff3c28cbd..cf5967865fe2 100644 --- a/python/mach/mach/dispatcher.py +++ b/python/mach/mach/dispatcher.py @@ -145,6 +145,7 @@ class CommandAction(argparse.Action): # arguments corresponding to command names. This has the side-effect # that argparse renders it nicely. r = self._mach_registrar + disabled_commands = [] cats = [(k, v[2]) for k, v in r.categories.items()] sorted_cats = sorted(cats, key=itemgetter(1), reverse=True) @@ -169,6 +170,9 @@ class CommandAction(argparse.Action): is_filtered = True break if is_filtered: + description = handler.description + disabled_command = {'command': command, 'description': description} + disabled_commands.append(disabled_command) continue if group is None: @@ -179,6 +183,13 @@ class CommandAction(argparse.Action): group.add_argument(command, help=description, action='store_true') + if disabled_commands: + title, description, _priority = r.categories['disabled'] + group = parser.add_argument_group(title, description) + for c in disabled_commands: + group.add_argument(c['command'], help=c['description'], + action='store_true') + parser.print_help() def _handle_subcommand_help(self, parser, command):