Skip to content

Commit 0cd5155

Browse files
committed
Return result of jar execution in func
1 parent 0c26048 commit 0cd5155

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

openapi_generator_cli/__init__.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""A Python wrapper for the OpenAPI Generator CLI."""
2+
13
from __future__ import annotations
24

35
import importlib.resources
@@ -6,7 +8,19 @@
68
import sys
79

810

9-
def run(args: list[str] | None = None) -> None:
11+
def run(args: list[str] | None = None) -> subprocess.CompletedProcess[bytes]:
12+
"""Run the OpenAPI Generator CLI with the given arguments.
13+
14+
Args:
15+
args (list[str], optional):
16+
The list of arguments to pass to the Open
17+
API Generator CLI. If not provided, the CLI will
18+
be run without any arguments.
19+
20+
Returns:
21+
subprocess.CompletedProcess[bytes]: The result of running the OpenAPI Generator CLI.
22+
23+
"""
1024
arguments = ["java"]
1125

1226
java_opts = os.getenv("JAVA_OPTS")
@@ -18,13 +32,14 @@ def run(args: list[str] | None = None) -> None:
1832
jar_path = importlib.resources.files("openapi_generator_cli") / "openapi-generator.jar"
1933
arguments.append(str(jar_path))
2034

21-
if args and type(args) == list:
35+
if args and isinstance(args, list):
2236
arguments.extend(args)
2337

24-
subprocess.call(arguments) # noqa: S603
38+
return subprocess.run(arguments, check=False) # noqa: S603
2539

2640

2741
def cli() -> None:
42+
"""Run the OpenAPI Generator CLI with the arguments provided on the command line."""
2843
args = []
2944
if len(sys.argv) > 1:
3045
args = sys.argv[1:]

0 commit comments

Comments
 (0)