def _get_all_commands()

in azdev/operations/cmdcov/cmdcov.py [0:0]


    def _get_all_commands(self):
        """
        GLOBAL_EXCLUDE_COMMANDS: List[str]
        EXCLUDE_COMMANDS: Dict[str: List[str]]
        exclusions_comands: List[str]
        exclude_parameters: List[List[str]]
        exclusions_parameters: List[Tuple[str, str]]
        get all commands from loaded_help
        """
        exclude_parameters = []
        exclude_parameters += GLOBAL_PARAMETERS + GENERIC_UPDATE_PARAMETERS + WAIT_CONDITION_PARAMETERS + \
            OTHER_PARAMETERS
        exclude_parameters = [sorted(i) for i in exclude_parameters]

        # some module like vm have multiple command like vm vmss disk snapshot ...
        # pylint: disable=too-many-nested-blocks, too-many-boolean-expressions
        exclusions_comands = []
        exclusions_parameters = []
        for c, v in self.exclusions.items():
            if 'parameters' in v:
                for p, r in v['parameters'].items():
                    if 'missing_parameter_test_coverage' in r['rule_exclusions']:
                        exclusions_parameters.append((c, p))
            elif 'rule_exclusions' in v:
                if 'missing_command_test_coverage' in v['rule_exclusions']:
                    exclusions_comands.append(c)
        print("\033[31m" + "Get all commands".center(self.width, self.fillchar) + "\033[0m")
        time.sleep(0.1)
        for _, y in tqdm(self.loaded_help.items()):
            module = None
            if hasattr(y, 'command_source') and y.command_source in self.selected_mod_names:
                module = y.command_source
            elif hasattr(y, 'command_source') and hasattr(y.command_source, 'extension_name'):
                ext_name = y.command_source.extension_name
                full_ext_name = 'azext_' + ext_name.replace('-', '_')
                if ext_name in self.selected_mod_names:
                    module = ext_name
                elif full_ext_name in self.selected_mod_names:
                    module = full_ext_name
            else:
                continue
            if (not y.deprecate_info) and module:
                if y.command.split()[-1] not in GLOBAL_EXCLUDE_COMMANDS and \
                        y.command not in EXCLUDE_COMMANDS.get(module, []) and \
                        y.command not in exclusions_comands:
                    if self.level == 'argument':
                        for parameter in y.parameters:
                            # TODO support linter_exclusions.yml
                            if sorted(parameter.name_source) not in exclude_parameters:
                                opt_list = [opt for opt in parameter.name_source if opt.startswith('-')]
                                if opt_list:
                                    self.all_commands[module].append(f'{y.command} {opt_list}')
                    else:
                        self.all_commands[module].append(f'{y.command}')