diff --git a/src/nomad_polymerization_reactions/cli.py b/src/nomad_polymerization_reactions/cli.py index 9283b24..dcf3851 100644 --- a/src/nomad_polymerization_reactions/cli.py +++ b/src/nomad_polymerization_reactions/cli.py @@ -20,12 +20,14 @@ def cli(): ) @click.argument( 'JSON_FILE_PATH', + nargs=-1, required=True, type=click.Path(exists=True), ) def _create_archive(json_file_path): try: - generate_archive_from_json(json_file_path) - click.echo('Archive created successfully.') + for file_path in json_file_path: + generate_archive_from_json(file_path) + click.echo('Archive created successfully.') except Exception as e: click.echo(f'Archive creation failed. Error: {e}') diff --git a/tests/test_cli.py b/tests/test_cli.py index f02a87d..0d5c46c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,3 +1,4 @@ +import glob import os from click.testing import CliRunner @@ -23,10 +24,12 @@ def test_create_archive_help(): def test_create_archive_success(): - result = invoke_cli( - cli, - ['create-archive', 'tests/data/processed_reactions/paper_0_reaction_1.json'], - ) + files = glob.glob('tests/data/processed_reactions/*.json') + result = invoke_cli(cli, ['create-archive', *files]) assert result.exit_code == 0 - assert 'Archive created successfully.' in result.output - os.remove('paper_0_reaction_1.archive.yaml') + assert ( + 'Archive created successfully.\nArchive created successfully.\n' + in result.output + ) + for file in files: + os.remove(file.split('/')[-1].replace('.json', '.archive.yaml'))