forked from clan/clan-core
clan: add dynamic completions for secret groups
This commit is contained in:
parent
b21bef0b98
commit
d4fabff7f4
@ -165,6 +165,28 @@ def complete_users(
|
||||
return users_dict
|
||||
|
||||
|
||||
def complete_groups(
|
||||
prefix: str, parsed_args: argparse.Namespace, **kwargs: Any
|
||||
) -> Iterable[str]:
|
||||
"""
|
||||
Provides completion functionality for clan groups
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
from .secrets.groups import list_groups
|
||||
|
||||
if (clan_dir_result := clan_dir(None)) is not None:
|
||||
flake = clan_dir_result
|
||||
else:
|
||||
flake = "."
|
||||
|
||||
groups_list = list_groups(Path(flake))
|
||||
groups = [group.name for group in groups_list]
|
||||
|
||||
groups_dict = {name: "group" for name in groups}
|
||||
return groups_dict
|
||||
|
||||
|
||||
def add_dynamic_completer(
|
||||
action: argparse.Action,
|
||||
completer: Callable[..., Iterable[str]],
|
||||
|
Loading…
Reference in New Issue
Block a user