Coverage for src/lexigram/notification/cli/contributor.py: 0%
25 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-26 07:17 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-26 07:17 +0800
1"""Notification CLI contributor definitions."""
3from __future__ import annotations
5from typing import Any
7from lexigram.contracts.cli.contributions import (
8 CommandContribution,
9 DoctorCheckContribution,
10 HealthCheckContribution,
11 SchemaSetupContribution,
12)
13from lexigram.contracts.cli.types import GeneratorDefinition
15# (name, description, generator_path, output_dir) — titles derive via make()
16_SPECS: tuple[tuple[str, str, str, str], ...] = (
17 (
18 "notification_template",
19 "Generate a notification template",
20 "lexigram.notification.cli.generators.template:NotificationTemplateGenerator",
21 "src/notifications",
22 ),
23)
25_GENERATOR_DEFINITIONS: tuple[GeneratorDefinition, ...] = tuple(
26 GeneratorDefinition.make(
27 name,
28 description=description,
29 generator_path=generator_path,
30 output_dir=output_dir,
31 contributor="notification",
32 category="notification",
33 )
34 for name, description, generator_path, output_dir in _SPECS
35)
38class NotificationCliContributor:
39 """CLI contributor for the lexigram-notification package."""
41 @property
42 def contributor_id(self) -> str:
43 """Return the contributor identifier."""
44 return "notification"
46 def get_generators(self) -> list[GeneratorDefinition]:
47 """Return generator definitions for notification."""
48 return list(_GENERATOR_DEFINITIONS)
50 def get_commands(self) -> list[CommandContribution]:
51 """Return the contributed `notify` command group."""
52 return [
53 CommandContribution(
54 name="notify",
55 help="Notification channel management commands",
56 app_factory_path="lexigram.notification.cli.commands:create_notify_app",
57 contributor="notification",
58 category="notification",
59 requires_app_context=True,
60 ),
61 ]
63 def get_health_checks(self) -> list[HealthCheckContribution]:
64 """Return notification channel health checks."""
65 return [
66 HealthCheckContribution(
67 name="notification_channels",
68 description="Check notification channels are reachable",
69 check_path="lexigram.notification.cli.checks:check_notification_channels",
70 contributor="notification",
71 category="notification",
72 timeout=15.0,
73 ),
74 ]
76 def get_doctor_checks(self) -> list[DoctorCheckContribution]:
77 """Return notification configuration doctor checks."""
78 return [
79 DoctorCheckContribution(
80 name="smtp_configured",
81 description="Check SMTP configuration is present",
82 check_path="lexigram.notification.cli.doctor:check_smtp_config",
83 contributor="notification",
84 category="notification",
85 ),
86 DoctorCheckContribution(
87 name="push_credentials_configured",
88 description="Check push notification credentials are configured",
89 check_path="lexigram.notification.cli.doctor:check_push_credentials",
90 contributor="notification",
91 category="notification",
92 ),
93 ]
95 def get_shell_context(self) -> list[Any]:
96 """Return no shell context contributions."""
97 return []
99 def get_hooks(self) -> list[Any]:
100 """Return no hook contributions."""
101 return []
103 def get_schema_setup(self) -> list[SchemaSetupContribution]:
104 """Return schema setup contributions for notification."""
105 return [
106 SchemaSetupContribution(
107 name="notification.inbox_messages",
108 description="In-app notification inbox storage",
109 setup_fn_path="lexigram.notification.cli.schema_setup:ensure_inbox_messages",
110 contributor=self.contributor_id,
111 ),
112 ]
115__all__ = ["NotificationCliContributor"]