Skip to content

Commit 8304331

Browse files
committed
changed: Allow running generator as Python Module in addition to CLI command
1 parent 91bc843 commit 8304331

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

openapi_generator_cli/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66

77

8-
def run():
8+
def run(args=None):
99
arguments = ["java"]
1010

1111
if os.getenv("JAVA_OPTS"):
@@ -18,7 +18,16 @@ def run():
1818
)
1919
arguments.append(jar_path)
2020

21-
if len(sys.argv) > 1:
22-
arguments.extend(sys.argv[1:])
21+
if args and type(args)==list:
22+
arguments.extend(args)
2323

2424
subprocess.call(" ".join(arguments), shell=True)
25+
26+
def cli():
27+
args = []
28+
if len(sys.argv) > 1:
29+
args = sys.argv[1:]
30+
run(args)
31+
32+
if __name__ == "__main__":
33+
cli()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ def run(self):
7474
"Programming Language :: Python :: Implementation :: PyPy",
7575
],
7676
cmdclass={"upload": UploadCommand},
77-
entry_points={"console_scripts": ["openapi-generator=openapi_generator_cli:run"]},
77+
entry_points={"console_scripts": ["openapi-generator=openapi_generator_cli:cli"]},
7878
)

0 commit comments

Comments
 (0)