Important: Please read the Qt Code of Conduct -

macOS QCommandLineParser missing --help/--version output

  • On a macOS (10.14.6) terminal an app bundle can be executed like open --args --input some.txt or open --args --help. The first one is a custom argument and works perfectly fine but the second on is a trouble maker. In the case of open --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: [options] [files]
      -h, --help          Displays this help.
      -v, --version     Displays version information.
      --input               Some stuff
      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?

  • Lifetime Qt Champion


    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. If Finder is used to run the app the same approach is used.

Log in to reply