discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Command line parsing

NH
nop head
Tue, Sep 25, 2018 8:27 AM

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,
the
file extension specifies the type: stl, off, amf,
csg,
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.

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, the file extension specifies the type: stl, off, amf, csg, 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.
TP
Torsten Paul
Tue, Sep 25, 2018 9:16 PM

On 09/25/2018 10:27 AM, nop head wrote:

Anybody know why allow_unregistered was used?

That was introduced in:
https://github.com/openscad/openscad/commit/752f35eab6c7b20d188bc36836e622665c8eba42

IIRC that was due to MacOS passing some extra parameters in some cases.

ciao,
Torsten.

On 09/25/2018 10:27 AM, nop head wrote: > Anybody know why allow_unregistered was used? > That was introduced in: https://github.com/openscad/openscad/commit/752f35eab6c7b20d188bc36836e622665c8eba42 IIRC that was due to MacOS passing some extra parameters in some cases. ciao, Torsten.
NH
nop head
Tue, Sep 25, 2018 10:42 PM

Doesn't this fix that problem?
https://github.com/openscad/openscad/blob/master/src/openscad.cc#L846. I
think it came later.

I have never known any other program accept random parameters silently. It
it needs to on a Mac it should be Mac specific.

On 25 September 2018 at 22:16, Torsten Paul Torsten.Paul@gmx.de wrote:

On 09/25/2018 10:27 AM, nop head wrote:

Anybody know why allow_unregistered was used?

That was introduced in:
https://github.com/openscad/openscad/commit/752f35eab6c7b20d
188bc36836e622665c8eba42

IIRC that was due to MacOS passing some extra parameters in some cases.

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Doesn't this fix that problem? https://github.com/openscad/openscad/blob/master/src/openscad.cc#L846. I think it came later. I have never known any other program accept random parameters silently. It it needs to on a Mac it should be Mac specific. On 25 September 2018 at 22:16, Torsten Paul <Torsten.Paul@gmx.de> wrote: > On 09/25/2018 10:27 AM, nop head wrote: > >> Anybody know why allow_unregistered was used? >> > > > That was introduced in: > https://github.com/openscad/openscad/commit/752f35eab6c7b20d > 188bc36836e622665c8eba42 > > IIRC that was due to MacOS passing some extra parameters in some cases. > > ciao, > Torsten. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Wed, Sep 26, 2018 8:03 AM

This PR https://github.com/openscad/openscad/pull/2107 added the psn
argument for MAC. If that is the only extra parameter that OSX adds then we
can remove allow_unregistered().

On 25 September 2018 at 23:42, nop head nop.head@gmail.com wrote:

Doesn't this fix that problem? https://github.com/openscad/
openscad/blob/master/src/openscad.cc#L846. I think it came later.

I have never known any other program accept random parameters silently. It
it needs to on a Mac it should be Mac specific.

On 25 September 2018 at 22:16, Torsten Paul Torsten.Paul@gmx.de wrote:

On 09/25/2018 10:27 AM, nop head wrote:

Anybody know why allow_unregistered was used?

That was introduced in:
https://github.com/openscad/openscad/commit/752f35eab6c7b20d
188bc36836e622665c8eba42

IIRC that was due to MacOS passing some extra parameters in some cases.

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

This PR <https://github.com/openscad/openscad/pull/2107> added the psn argument for MAC. If that is the only extra parameter that OSX adds then we can remove allow_unregistered(). On 25 September 2018 at 23:42, nop head <nop.head@gmail.com> wrote: > Doesn't this fix that problem? https://github.com/openscad/ > openscad/blob/master/src/openscad.cc#L846. I think it came later. > > I have never known any other program accept random parameters silently. It > it needs to on a Mac it should be Mac specific. > > On 25 September 2018 at 22:16, Torsten Paul <Torsten.Paul@gmx.de> wrote: > >> On 09/25/2018 10:27 AM, nop head wrote: >> >>> Anybody know why allow_unregistered was used? >>> >> > >> That was introduced in: >> https://github.com/openscad/openscad/commit/752f35eab6c7b20d >> 188bc36836e622665c8eba42 >> >> IIRC that was due to MacOS passing some extra parameters in some cases. >> >> ciao, >> Torsten. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > >