Skip to content

Commit c3c1486

Browse files
authored
Merge pull request #2 from tomer/patch-1
Allow running generator as Python Module in addition to CLI command
2 parents 36e150d + 5449bfb commit c3c1486

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

openapi_generator_cli/__init__.py

Lines changed: 14 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,18 @@ 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+
27+
def cli():
28+
args = []
29+
if len(sys.argv) > 1:
30+
args = sys.argv[1:]
31+
run(args)
32+
33+
34+
if __name__ == "__main__":
35+
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)