From 8af49987e30a1e068b612ba56e969ab945d278fe Mon Sep 17 00:00:00 2001 From: Justin Buchanan Date: Mon, 20 Nov 2023 21:39:03 -0800 Subject: [PATCH] don't require entrypoint to contain show_object() --entrypoint is now just the name of a python function to call and show --- src/cq_cli/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cq_cli/main.py b/src/cq_cli/main.py index 475be33..9c22a09 100755 --- a/src/cq_cli/main.py +++ b/src/cq_cli/main.py @@ -28,7 +28,9 @@ def build_and_parse(script_str, params, errfile, entrypoint): try: # Do the CQGI handling of the script here and, if successful, pass the build result to the codec if entrypoint != None: - script_str += "\n" + entrypoint + if not entrypoint.isidentifier(): + raise ValueError("Entrypoint is not a valid python function name") + script_str += "\nshow_object({f}())".format(f=entrypoint) cqModel = cqgi.parse(script_str) build_result = cqModel.build(params) @@ -185,7 +187,7 @@ def main(): ) parser.add_argument( "--entrypoint", - help="A snippet of python code to append to the input file before rendering. This allows rendering different models/parts from the same python file.", + help="The name of a python function that returns a cadquery model object. cq-cli will call the function and render the resulting object. This allows rendering different models/parts from the same python file.", ) args = parser.parse_args()