Coverage for src/lexigram/features/cli/contributor.py: 0%

22 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-26 01:53 +0800

1"""Features CLI contributor definitions.""" 

2 

3from __future__ import annotations 

4 

5from typing import Any 

6 

7from lexigram.contracts.cli.contributions import ( 

8 CommandContribution, 

9 DoctorCheckContribution, 

10 HealthCheckContribution, 

11 ShellContextContribution, 

12) 

13from lexigram.contracts.cli.types import GeneratorDefinition 

14 

15_GENERATOR_DEFINITIONS: tuple[GeneratorDefinition, ...] = ( 

16 GeneratorDefinition( 

17 name="feature_flag", 

18 title="Generate Feature Flag", 

19 description="Generate a feature flag definition", 

20 contributor="features", 

21 generator_path="lexigram.features.cli.generators.flag:FeatureFlagGenerator", 

22 default_output_dir="src/features", 

23 category="features", 

24 ), 

25) 

26 

27 

28class FeaturesCliContributor: 

29 """CLI contributor for the lexigram-features package.""" 

30 

31 @property 

32 def contributor_id(self) -> str: 

33 """Return the contributor identifier.""" 

34 return "features" 

35 

36 def get_generators(self) -> list[GeneratorDefinition]: 

37 """Return generator definitions for features.""" 

38 return list(_GENERATOR_DEFINITIONS) 

39 

40 def get_commands(self) -> list[CommandContribution]: 

41 """Return the contributed `features` command group.""" 

42 return [ 

43 CommandContribution( 

44 name="features", 

45 help="Feature flag management commands", 

46 app_factory_path="lexigram.features.cli.commands:create_features_app", 

47 contributor="features", 

48 category="features", 

49 requires_app_context=True, 

50 ), 

51 ] 

52 

53 def get_health_checks(self) -> list[HealthCheckContribution]: 

54 """Return feature flag manager health checks.""" 

55 return [ 

56 HealthCheckContribution( 

57 name="flag_manager_status", 

58 description="Check feature flag manager is operational", 

59 check_path="lexigram.features.cli.checks:check_flag_manager", 

60 contributor="features", 

61 category="features", 

62 timeout=5.0, 

63 ), 

64 ] 

65 

66 def get_doctor_checks(self) -> list[DoctorCheckContribution]: 

67 """Return features configuration doctor checks.""" 

68 return [ 

69 DoctorCheckContribution( 

70 name="features_config_valid", 

71 description="Validate features section in application.yaml", 

72 check_path="lexigram.features.cli.doctor:check_features_config", 

73 contributor="features", 

74 category="features", 

75 ), 

76 ] 

77 

78 def get_shell_context(self) -> list[ShellContextContribution]: 

79 """Return flag manager shell context.""" 

80 return [ 

81 ShellContextContribution( 

82 name="flags", 

83 description="FlagManager for interactive feature flag management", 

84 factory_path="lexigram.features.cli.shell:provide_flag_manager", 

85 contributor="features", 

86 ), 

87 ] 

88 

89 def get_hooks(self) -> list[Any]: 

90 """Return no hook contributions.""" 

91 return [] 

92 

93 

94__all__ = ["FeaturesCliContributor"]