Solved macOS QCommandLineParser missing --help/--version output
-
On a macOS (10.14.6) terminal an app bundle can be executed like
open mytool.app --args --input some.txt
oropen mytool.app --args --help
. The first one is a custom argument and works perfectly fine but the second on is a trouble maker. In the case ofopen mytool.app --args --help
the app gets properly executed but there is now output in the terminal. My expectation was to see similar output like on the other platforms (Linux, Windows). The implemenation is always the same, which uses QCommandLineParser::showHelp() and QCommandLineParser::showVersion() and on Linux/Windows the code produces text like shown below.Usage: mytool.app [options] [files] Options: -h, --help Displays this help. -v, --version Displays version information. --input Some stuff Arguments: files List of files to be opened.
Because the code is working well on Linux and Windows I think it is a macOS specific issue. Is my expectation wrong? Do you have a hint what causes the problem?
-
Hi,
For the help part, I would rather call the executable from the bundle directly rather than calling open. Note that I might be old fashioned with regard to that.
-
Hi @sgaist, your suggestion is the way to go. I just learned that
open
does not start a sub-process. Instead a message is send to the OS launch system, which then executes the app. IfFinder
is used to run the app the same approach is used.