in hydra/plugins/completion_plugin.py [0:0]
def _query_config_groups(self, word: str) -> Tuple[List[str], bool]:
is_addition = word.startswith("+")
is_deletion = word.startswith("~")
if is_addition or is_deletion:
prefix, word = word[0], word[1:]
else:
prefix = ""
last_eq_index = word.rfind("=")
last_slash_index = word.rfind("/")
exact_match: bool = False
if last_eq_index != -1:
parent_group = word[0:last_eq_index]
results_filter = ObjectType.CONFIG
else:
results_filter = ObjectType.GROUP
if last_slash_index == -1:
parent_group = ""
else:
parent_group = word[0:last_slash_index]
all_matched_groups = self.config_loader.get_group_options(
group_name=parent_group, results_filter=results_filter
)
matched_groups: List[str] = []
if results_filter == ObjectType.CONFIG:
for match in all_matched_groups:
name = f"{parent_group}={match}" if parent_group != "" else match
if name.startswith(word):
matched_groups.append(name)
exact_match = True
elif results_filter == ObjectType.GROUP:
for match in all_matched_groups:
name = f"{parent_group}/{match}" if parent_group != "" else match
if name.startswith(word):
files = self.config_loader.get_group_options(
group_name=name, results_filter=ObjectType.CONFIG
)
dirs = self.config_loader.get_group_options(
group_name=name, results_filter=ObjectType.GROUP
)
if len(dirs) == 0 and len(files) > 0 and not is_deletion:
name = name + "="
elif len(dirs) > 0 and len(files) == 0:
name = name + "/"
matched_groups.append(name)
matched_groups = [f"{prefix}{group}" for group in matched_groups]
return matched_groups, exact_match