Repository: spdx/tools-python

Issue:
CLI raises error if no arguments provided
If we only call `pyspdxtools` without any argument an `AttributeError` is raised. We should instead give a hint on how to correctly use the CLI and which arguments are possible. 

Discussion:

Patch:
diff --git a/src/spdx/clitools/pyspdxtools.py b/src/spdx/clitools/pyspdxtools.py
index e246176..f2d480e 100644
--- a/src/spdx/clitools/pyspdxtools.py
+++ b/src/spdx/clitools/pyspdxtools.py
@@ -29,7 +29,7 @@ from spdx.writer.write_anything import write_file
 
 
 @click.command()
-@click.option("--infile", "-i", help="The file containing the document to be validated or converted.")
+@click.option("--infile", "-i", required=True, help="The file containing the document to be validated or converted.")
 @click.option(
     "--outfile",
     "-o",


Test patch:
diff --git a/tests/spdx/test_cli.py b/tests/spdx/test_cli.py
new file mode 100644
index 0000000..3966039
--- /dev/null
+++ b/tests/spdx/test_cli.py
@@ -0,0 +1,45 @@
+import os
+
+import pytest
+from click.testing import CliRunner
+
+from spdx.clitools.pyspdxtools import main
+
+
+@pytest.mark.parametrize(
+    "options",
+    [
+        ("--infile", os.path.join(os.path.dirname(__file__), "data/SPDXJSONExample-v2.3.spdx.json")),
+        ("-i", os.path.join(os.path.dirname(__file__), "data/SPDXJSONExample-v2.3.spdx.json"), "--novalidation"),
+        (
+            "-i",
+            os.path.join(os.path.dirname(__file__), "data/SPDXJSONExample-v2.3.spdx.json"),
+            "--novalidation",
+            "--version",
+            "SPDX-2.3",
+        ),
+        ("-i", os.path.join(os.path.dirname(__file__), "data/SPDXJSONExample-v2.3.spdx.json"), "-o", "-"),
+    ],
+)
+def test_cli_with_system_exit_code_0(options):
+    runner = CliRunner()
+
+    result = runner.invoke(main, options)
+
+    assert result.exit_code == 0
+
+
+@pytest.mark.parametrize(
+    "options",
+    [
+        (),
+        ("-i", os.path.join(os.path.dirname(__file__), "data/SPDXJSONExample-v2.3.spdx.json"), "--version"),
+        ("-i", os.path.join(os.path.dirname(__file__), "data/SPDXJSONExample-v2.3.spdx.json"), "-o"),
+    ],
+)
+def test_cli_with_system_exit_code_2(options):
+    runner = CliRunner()
+
+    result = runner.invoke(main, options)
+
+    assert result.exit_code == 2