Skip to content

Add QCommandLineParser support #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from

Conversation

Montel
Copy link
Contributor

@Montel Montel commented Nov 28, 2023

No description provided.

@Montel Montel self-assigned this Nov 28, 2023
@Be-ing
Copy link
Contributor

Be-ing commented Nov 29, 2023

What's the use case for using this rather than clap or some other Rust library for command line argument parsing?

@Montel
Copy link
Contributor Author

Montel commented Nov 29, 2023

CommandLineParser allows to add some specific Qt option directly.
I think it can be useful for Qt user which wants to use cxx-qt

@Be-ing
Copy link
Contributor

Be-ing commented Nov 29, 2023

I don't really understand the point of binding this. A Rust CLI argument parsing library is probably going to be easier to use in any case. If the main function is in C++, there's no need for the Rust binding because QCommandLineParser can easily be used directly. It doesn't hurt to merge this except for the maintenance burden, so if @ahayzen-kdab and @LeonMatthesKDAB are fine with that, go ahead, but there are lots more Qt APIs that would be more useful to work on binding.

@ahayzen-kdab
Copy link
Collaborator

Right, for writing a Rust CLI it would be something like clap and a Qt/C++ app would use QCommandLineParser on the C++ side.

Is there any usecase for things like -platform xcb does QCommandLineParser automatically handle these ? Or is that handled elsewhere ?

As @Be-ing says we have been trying to keep the maintenance burden and the build times 😅 low by only binding the most useful things so far.

@Be-ing
Copy link
Contributor

Be-ing commented Nov 29, 2023

Is there any usecase for things like -platform xcb does QCommandLineParser automatically handle these ? Or is that handled elsewhere ?

We already take care of standard Qt CLI arguments like -platform xcb appropriately by passing CLI args from Q[Core/Gui]Application::new in Rust to the respective C++ constructors. There's no need for QCommandLineParser to interface with that.

@Montel
Copy link
Contributor Author

Montel commented Nov 29, 2023

When we look at all option we can see

  --qmljsdebugger <value>              Activates the QML/JS debugger with a
                                       specified port. The value must be of
                                       format port:1234[,block]. "block" makes
                                       the application wait for a connection.
  --platform <platformName[:options]>  QPA plugin. See QGuiApplication
                                       documentation for available options for
                                       each plugin.
  --platformpluginpath <path>          Path to the platform plugins.
  --platformtheme <theme>              Platform theme.
  --plugin <plugin>                    Additional plugins to load, can be
                                       specified multiple times.
  --qwindowgeometry <geometry>         Window geometry for the main window,
                                       using the X11-syntax, like 100x100+50+50.
  --qwindowicon <icon>                 Default window icon.
  --qwindowtitle <title>               Title of the first window.
  --reverse                            Sets the application's layout direction
                                       to Qt::RightToLeft (debugging helper).
  --session <session>                  Restores the application from an earlier
                                       session.
  --display <display>                  Display name, overrides $DISPLAY.
  --name <name>                        Instance name according to ICCCM
                                       4.1.2.5.
  --nograb                             Disable mouse grabbing (useful in
                                       debuggers).
  --dograb                             Force mouse grabbing (even when running
                                       in a debugger).
  --visual <id>                        ID of the X11 Visual to use.
  --geometry <geometry>                Alias for --qwindowgeometry.
  --icon <icon>                        Alias for --qwindowicon.
  --title <title>                      Alias for --qwindowtitle.

It's provided automatically by Qt directly.
Not sure if we can see it when we use " --help-all"

@Montel
Copy link
Contributor Author

Montel commented Nov 29, 2023

It depends if we think that cxx-qt is only for rust user which wants to use Qt/QML interface so for sure it can be easy to add "clap" rust module directly.
For me for Qt user which wants to use it, it can be more easy to use known api.

But indeed it depends about the target of cxx-qt.

@Be-ing
Copy link
Contributor

Be-ing commented Nov 29, 2023

If you prefer to use QCommandLineParser over Rust CLI argument parsing libraries, then I think it would be easier to have your main function in C++ and use QCommandLineParser directly from C++ than have your main function in Rust and use Rust bindings to QCommandLineParser.

@LeonMatthesKDAB
Copy link
Collaborator

I've added an issue regarding CXX-Qt-lib-extra here: #766

As we seem to venture into this territory now reasonably often.

@Montel Montel closed this Feb 23, 2024
@Montel
Copy link
Contributor Author

Montel commented Feb 23, 2024

Merge in #860

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants