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
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-12 10:26 +0000
1import sys
3from pydantic import BaseModel
4from pydantic_settings import BaseSettings, CliSubCommand
6from ._summarize import summarize_reports
7from .index import create_index
10class CmdBase(BaseModel, use_attribute_docstrings=True, cli_implicit_flags=True):
11 pass
14class IndexCmd(CmdBase):
15 def run(self):
16 """Index the bioimage.io collection"""
17 _ = create_index()
20class SummarizeCmd(CmdBase):
21 def run(self):
22 """Conflate tool summaries"""
24 summarize_reports()
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"""
38 index: CliSubCommand[IndexCmd]
39 """index the bioimage.io collection"""
41 summarize: CliSubCommand[SummarizeCmd]
42 """conflate tool summaries"""
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())