Repository: ResearchObject/ro-crate-py (python)

Issue:
write-zip CLI command reinitializes the crate
The `write-zip` CLI command reinitializes the crate, so any changes like adding a workflow or test suite are lost.

Pull request description:
Fix write-zip CLI command
Fixes #108.

Patch:
diff --git a/rocrate/cli.py b/rocrate/cli.py
index 250a448..7d8dad7 100644
--- a/rocrate/cli.py
+++ b/rocrate/cli.py
@@ -120,7 +120,7 @@ def definition(state, suite, path, engine, engine_version):
 @click.argument('dst', type=click.Path(writable=True))
 @click.pass_obj
 def write_zip(state, dst):
-    crate = ROCrate(state.crate_dir, init=True, gen_preview=False)
+    crate = ROCrate(state.crate_dir, init=False, gen_preview=False)
     crate.write_zip(dst)
 
 


Test patch:
diff --git a/test/test_cli.py b/test/test_cli.py
index 31b701d..bcfe14f 100644
--- a/test/test_cli.py
+++ b/test/test_cli.py
@@ -21,6 +21,7 @@ from click.testing import CliRunner
 
 from rocrate.cli import cli
 from rocrate.model.metadata import TESTING_EXTRA_TERMS
+from rocrate.rocrate import ROCrate
 
 
 @pytest.mark.parametrize("gen_preview,cwd", [(False, False), (False, True), (True, False), (True, True)])
@@ -137,6 +138,9 @@ def test_cli_write_zip(test_data_dir, monkeypatch, cwd):
     crate_dir = test_data_dir / "ro-crate-galaxy-sortchangecase"
     runner = CliRunner()
     assert runner.invoke(cli, ["-c", str(crate_dir), "init"]).exit_code == 0
+    wf_path = crate_dir / "sort-and-change-case.ga"
+    args = ["-c", str(crate_dir), "add", "workflow", str(wf_path)]
+    assert runner.invoke(cli, args).exit_code == 0
 
     output_zip_path = test_data_dir / "test-zip-archive.zip"
     args = []
@@ -150,3 +154,6 @@ def test_cli_write_zip(test_data_dir, monkeypatch, cwd):
     result = runner.invoke(cli, args)
     assert result.exit_code == 0
     assert output_zip_path.is_file()
+
+    crate = ROCrate(output_zip_path)
+    assert crate.mainEntity is not None