Coverage for src/backoffice/_cli.py: 0%

21 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-11-12 10:26 +0000

1import sys 

2 

3from pydantic import BaseModel 

4from pydantic_settings import BaseSettings, CliSubCommand 

5 

6from ._summarize import summarize_reports 

7from .index import create_index 

8 

9 

10class CmdBase(BaseModel, use_attribute_docstrings=True, cli_implicit_flags=True): 

11 pass 

12 

13 

14class IndexCmd(CmdBase): 

15 def run(self): 

16 """Index the bioimage.io collection""" 

17 _ = create_index() 

18 

19 

20class SummarizeCmd(CmdBase): 

21 def run(self): 

22 """Conflate tool summaries""" 

23 

24 summarize_reports() 

25 

26 

27class Backoffice( 

28 BaseSettings, 

29 cli_implicit_flags=True, 

30 cli_parse_args=True, 

31 cli_kebab_case=True, 

32 cli_prog_name="backoffice", 

33 cli_use_class_docs_for_groups=True, 

34 use_attribute_docstrings=True, 

35): 

36 """backoffice - manage the bioimage.io collection""" 

37 

38 index: CliSubCommand[IndexCmd] 

39 """index the bioimage.io collection""" 

40 

41 summarize: CliSubCommand[SummarizeCmd] 

42 """conflate tool summaries""" 

43 

44 def run(self): 

45 cmd = self.index or self.summarize 

46 if cmd is None: 

47 raise ValueError( 

48 "No command specified. Use 'backoffice --help' to see available commands." 

49 ) 

50 else: 

51 sys.exit(cmd.run())