Coverage for src / rhiza / __main__.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-02 07:04 +0000

1"""Rhiza module entry point. 

2 

3This module allows running the Rhiza CLI with `python -m rhiza` by 

4delegating execution to the Typer application defined in `rhiza.cli`. 

5""" 

6 

7from importlib.metadata import entry_points 

8 

9import typer 

10from loguru import logger 

11 

12from rhiza.cli import app 

13 

14 

15def load_plugins(app: typer.Typer) -> None: 

16 """Load plugins from entry points.""" 

17 # 'rhiza.plugins' matches the group we defined in rhiza-tools 

18 plugin_entries = entry_points(group="rhiza.plugins") 

19 

20 for entry in plugin_entries: 

21 try: 

22 plugin_app = entry.load() 

23 # This adds the plugin as a subcommand, e.g., 'rhiza tools bump' 

24 app.add_typer(plugin_app, name=entry.name) 

25 except Exception as e: 

26 logger.warning(f"Failed to load plugin {entry.name}: {e}") 

27 

28 

29if __name__ == "__main__": 

30 load_plugins(app) 

31 

32 app()