[docs]defapp_labels(ctx:Context,param:Parameter,incomplete:str)->t.List[CompletionItem]:""" A case-sensitive completer for Django app labels or names. The completer prefers labels but names will also work. .. code-block:: python import typing as t import typer from django_typer.management import TyperCommand from django_typer.parsers import parse_app_label from django_typer.completers import complete_app_label class Command(TyperCommand): def handle( self, django_apps: t.Annotated[ t.List[AppConfig], typer.Argument( parser=parse_app_label, shell_complete=complete_app_label, help=_("One or more application labels.") ) ] ): ... :param ctx: The click context. :param param: The click parameter. :param incomplete: The incomplete string. :return: A list of matching app labels or names. Labels already present for the parameter on the command line will be filtered out. """present=[]if(param.nameandctx.get_parameter_source(param.name)isnotParameterSource.DEFAULT):present=[app.labelforappin(ctx.params.get(param.name)or[])]ret=[CompletionItem(app.label)forappinapps.get_app_configs()ifapp.label.startswith(incomplete)andapp.labelnotinpresent]ifnotretandincomplete:ret=[CompletionItem(app.name)forappinapps.get_app_configs()ifapp.name.startswith(incomplete)andapp.namenotinpresentandapp.labelnotinpresent]returnret