Coverage for src/shephex/cli/study/build.py: 75%

12 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-06-20 14:13 +0200

1from pathlib import Path 

2 

3import rich_click as click 

4 

5from shephex.cli.study.main import study_cli 

6from shephex.study import Study 

7 

8 

9@study_cli.command("build") 

10@click.argument("directory", type=click.Path(exists=True, file_okay=False)) 

11@click.option( 

12 "--avoid-duplicates", 

13 is_flag=True, 

14 default=False, 

15 help="Avoid duplicates in the study.", 

16) 

17@click.option('dump_path', '--dump-path', type=click.Path(), default=None, help="Path to dump the study.") 

18def build_study( 

19 directory: Path, 

20 avoid_duplicates: bool, 

21 dump_path: Path | None, 

22) -> None: 

23 """ 

24 Build a study from the given directory. 

25 """ 

26 study = Study(directory, refresh=False, avoid_duplicates=avoid_duplicates) 

27 study.refresh(clear_table=True, progress_bar=True) 

28 study.dump(path=dump_path)