diff --git a/CHANGELOG b/CHANGELOG index c54ee33..d873c51 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ 0.11.2 - fix: `python -m chipstream.cli` failed with ModuleNotFoundError + - fix: `chipstream-cli --recursive` silently did nothing when PATH_IN is a file 0.11.1 - enh: don't show rounded 100% in CLI progress - setup: bump dcnum to 0.31.2 diff --git a/chipstream/cli/cli_main.py b/chipstream/cli/cli_main.py index 8d9058d..3500b7b 100644 --- a/chipstream/cli/cli_main.py +++ b/chipstream/cli/cli_main.py @@ -219,7 +219,12 @@ def chipstream_cli( debug=debug, ) - if recursive: + if recursive and not path_in.is_dir(): + click.secho(f"PATH_IN must be a directory in recursive mode, but " + f"'{path_in}' is a file. Omit the `--recursive` flag " + f"to process a single file.", fg="red") + exit_code = 1 + elif recursive: failed = 0 # keeps track of files that failed to process for pi in sorted(path_in.rglob("*.rtdc")): if pi.name.endswith("_dcn.rtdc"): diff --git a/tests/test_cli.py b/tests/test_cli.py index 8379d55..58e8a0b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -216,6 +216,17 @@ def test_cli_python_m(): assert chipstream.__version__ in result.stdout +def test_cli_recursive_with_file(cli_runner): + """Recursive mode requires a directory as input""" + path = retrieve_data( + "fmt-hdf5_cytoshot_full-features_legacy_allev_2023.zip") + result = cli_runner.invoke(cli_main.chipstream_cli, + [str(path), "--recursive"]) + assert result.exit_code == 1 + assert result.stdout.count("must be a directory in recursive mode") + assert not path.with_name(path.stem + "_dcn.rtdc").exists() + + def test_cli_set_pixel_size(cli_runner): path_temp = retrieve_data( "fmt-hdf5_cytoshot_full-features_legacy_allev_2023.zip")