[OpenSCAD] Command line parsing

nop head nop.head at gmail.com
Tue Sep 25 04:27:53 EDT 2018

I noticed OpenSCAD doesn't complain if you specify non existent options,
e.g. --fred. This is because the command line parser allow_unregistered()
member function is called. Removing this makes it throw an error, which is
caught and printed with the usage message.

./release/openscad.exe --fred -v
unrecognised option '--fred'

Usage: openscad.exe [options] file.scad
Allowed options:
  -o [ --o ] arg        out_file -output a file instead of running the GUI,
                        file extension specifies the type: stl, off, amf,
                        dxf, svg, png, echo, ast, term, nef3, nefdbg

I can't think of any reason for silently ignoring unrecognised options. And
this line seems to indicate it that was not the intension:

catch(const std::exception &e) { // Catches e.g. unknown options

Anybody know why allow_unregistered was used? With it I don't think
command_line_parser::run()  ever throws an exception. Certainly I haven't
found a way to make it do so. Normally if it is used something processes
the unknown options later but I can't see anything that does that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20180925/c94f342a/attachment.html>

More information about the Discuss mailing list