CmdLine::parse returns void and exits if 'shouldExit'.
When using TCLAP in an embedded application, this is inconvenient.
I have a shell for an ESP32 application to have a convenient interface for testing and setting parameters.
I can use a StdOutput derivative to ensure that cout and cerr is managed adequately.
But if parse exits when 'shouldExit' where the derived 'failure' can du that, parse can just return OK or NotOK to inform that the parse failed to let the user decide to exit the application.
Or let the StdOutput::failure do the exit so it is possible for the user to derive 'failure' to do the exit or continue based on the return value of 'parse'. This will (probably) preserve backward compatibility?
What I basically want is to be able to run the attached program to the end.
The program is based on tclap 1.4 included as 'Additional Include Directories'.
The program iterates 7 times with different args by calling tclap_main with different arguments. See stdio_testWin.cpp.
It never comes past the third iteration because it asks for the --version which exits due to CmdLine exiting.
It's a bit unclear what you are asking about and I haven't looked at th > 1MB zip file, but if I were to guess what you want to do is to disable exception handling in the CmdLine object. You can do that by calling
p.setExceptionHandling(false);. That way the application will receive any exception thrown during parsing and can choose how to deal with it. https://tclap.sourceforge.net/html/classTCLAP_1_1CmdLine.html#aa02055d8f4864bfa9b505e2d26bbbd87If this is specifically about
--versionyou can also disable it: https://tclap.sourceforge.net/manual.html#NO_HELP_VERSIONHi Daniel
Thanks for getting back this fast 😊
No, I overall like the TCLAP behaviour.
There is no need to disable any functionality; the exception handling is important in this context.
The goal is to use TCLAP in ESP32/FreeRTOS projects, i.e. embedded systems.
This implies that exit() is not an option because that will reset the embedded application.
Rather than exit(), CmdLine shall return with zero when everything is successful, and non-zero if parsing was unsuccessful.
Another thing is that TCLAP relies heavily on cout/cerr.
That should rather be some generic streams that can be implemented by the user.
Of course there shall be a default to cout/cerr.
The attachment is a Visual Studio project that makes several successive calls to CmdLine to illustrate how I want to use TCLAP.
It is only attached for convenience if there is something I haven’t made clear enough.
The general idea is that if TCLAP works in that environment, I have come a long way.
Then it will only be a matter of capturing cout/cerr.
The escape: If you only want to target Windows/Linux console programs, then disregard.
I could agree that embedded systems is outside your scope.
Anyway: I used TCLAP in an embedded environment (NIOS) at MAN Diesel 10 years ago 😊 but that environment is different from FreeRTOS.
Best regards
Carsten
From: feature-requests@tclap.p.re.sourceforge.net feature-requests@tclap.p.re.sourceforge.net On Behalf Of Daniel Aarno
Sent: 11. november 2025 10:53
To: [tclap:feature-requests] 28@feature-requests.tclap.p.re.sourceforge.net
Subject: [tclap:feature-requests] #28 CmdLine::parse return behaviour
It's a bit unclear what you are asking about and I haven't looked at th > 1MB zip file, but if I were to guess what you want to do is to disable exception handling in the CmdLine object. You can do that by calling p.setExceptionHandling(false); . That way the application will receive any exception thrown during parsing and can choose how to deal with it. https://tclap.sourceforge.net/html/classTCLAP_1_1CmdLine.html#aa02055d8f4864bfa9b505e2d26bbbd87
If this is specifically about --version you can also disable it: https://tclap.sourceforge.net/manual.html#NO_HELP_VERSION
[feature-requests:#28] https://sourceforge.net/p/tclap/feature-requests/28/ CmdLine::parse return behaviour
Status: open
Group: 1.4
Created: Sat Nov 08, 2025 09:17 PM UTC by Carsten Bøgh Poulsen
Last Updated: Sun Nov 09, 2025 12:24 PM UTC
Owner: nobody
CmdLine::parse returns void and exits if 'shouldExit'.
When using TCLAP in an embedded application, this is inconvenient.
I have a shell for an ESP32 application to have a convenient interface for testing and setting parameters.
I can use a StdOutput derivative to ensure that cout and cerr is managed adequately.
But if parse exits when 'shouldExit' where the derived 'failure' can du that, parse can just return OK or NotOK to inform that the parse failed to let the user decide to exit the application.
Or let the StdOutput::failure do the exit so it is possible for the user to derive 'failure' to do the exit or continue based on the return value of 'parse'. This will (probably) preserve backward compatibility?
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/tclap/feature-requests/28/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
Related
Feature Requests:
#28Please take another look, "the exception handling is important in this context." doesn't make sense. Either the exception is hanled inside parse and thus it will exit on error, or it will be thrown to the caller that can handle it. So instead of "return true/false" it will return nothing on success or throw an exception on error - that you can catch and decide what to do with.