diff --git a/rocolib/__main__.py b/rocolib/__main__.py index 5df484ccf782b001ef9a3789b642990adb2f0a82..39700c0e014157aa0269a9132dd189a9975cdc28 100644 --- a/rocolib/__main__.py +++ b/rocolib/__main__.py @@ -13,7 +13,12 @@ def test(component, params, thickness, display=False, display3D=False): f = getComponent(component) if params is not None: for p in params: - f.setParameter(p[0], eval(str(p[1]))) + try: + v = eval(str(p[1])) + except NameError: + # Using a string as a dimensions parameter + v = str(p[1]) + f.setParameter(p[0], v) if thickness is None: t = 0 j = None @@ -23,8 +28,7 @@ def test(component, params, thickness, display=False, display3D=False): f.makeOutput("output/" + component, display=display, display3D=display3D, thickness=t, joint=j) - -if __name__ == '__main__': +def cli_argparse(): LOG_LEVELS = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] DEFAULT_LOG_LEVEL = "WARNING" @@ -113,3 +117,6 @@ if __name__ == '__main__': if not acted: parser.print_help(sys.stderr) sys.exit(1) + +if __name__ == '__main__': + cli_argparse() \ No newline at end of file diff --git a/setup.py b/setup.py index 20bcdf0b4d0b6249944d0c91638363899130a6ea..c17117ffeb993ef68fb85d51ff2441a0b73e8dbb 100644 --- a/setup.py +++ b/setup.py @@ -52,4 +52,9 @@ setup( 'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)', 'Programming Language :: Python :: 3', ], + entry_points={ + 'console_scripts': [ + 'roco = rocolib.__main__:cli_argparse', + ] + }, )