clan: add dynamic completions for secret groups
This commit is contained in:
@@ -165,6 +165,28 @@ def complete_users(
|
|||||||
return users_dict
|
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(
|
def add_dynamic_completer(
|
||||||
action: argparse.Action,
|
action: argparse.Action,
|
||||||
completer: Callable[..., Iterable[str]],
|
completer: Callable[..., Iterable[str]],
|
||||||
|
|||||||
Reference in New Issue
Block a user