You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there. I am making a GTK application, and I would like to take command line arguments.
I can run a GTK application that ignores command line arguments that are passed, my code for this is
let app = gtk4::Application::builder().application_id("com.github.REALERvolker1.example").build();
app.run_with_args::<glib::GString>(&[]);
However, I would like to learn how to use GTK's built-in argument parsing, hopefully removing some dependencies. I know that it is definitely harder than clap or rolling my own custom one (requiring me to either hardcode or macro a bunch of stuff into oblivion), but I would like to try it.
I checked out the GTK documentation, and it seems like handle-local-options is the best way to do this. It won't give me as much control, but I would prefer to have the help page formatting from gtk, even if it does include the --help-all and --help-gapplication flags. I don't know if this is how that works, please do correct me if I'm wrong. I would like to use the nice layout that comes with this, and keep everything nice and structured. The help text requirement is also really nice imo.
I found that I have to add a bunch of gio::ActionEntry to the application. However, I don't know how that translates into CLI argument parsing, and how that interacts with the app.connect_command_line(|app, cli| {/* ... */}); handler.
I have seen the methods on the ApplicationCommandLine class, and it looks very featureful. Having an arg parsing example would really make this a lot easier to learn.
There is definitely interest in this see (#730), and it would also clear up some confusion with gtk weirdness (#1436, #1039)
The text was updated successfully, but these errors were encountered:
Hey there. I am making a GTK application, and I would like to take command line arguments.
I can run a GTK application that ignores command line arguments that are passed, my code for this is
However, I would like to learn how to use GTK's built-in argument parsing, hopefully removing some dependencies. I know that it is definitely harder than clap or rolling my own custom one (requiring me to either hardcode or macro a bunch of stuff into oblivion), but I would like to try it.
I checked out the GTK documentation, and it seems like
handle-local-options
is the best way to do this. It won't give me as much control, but I would prefer to have the help page formatting from gtk, even if it does include the--help-all
and--help-gapplication
flags. I don't know if this is how that works, please do correct me if I'm wrong. I would like to use the nice layout that comes with this, and keep everything nice and structured. The help text requirement is also really nice imo.I found that I have to add a bunch of
gio::ActionEntry
to the application. However, I don't know how that translates into CLI argument parsing, and how that interacts with theapp.connect_command_line(|app, cli| {/* ... */});
handler.I have seen the methods on the
ApplicationCommandLine
class, and it looks very featureful. Having an arg parsing example would really make this a lot easier to learn.There is definitely interest in this see (#730), and it would also clear up some confusion with gtk weirdness (#1436, #1039)
The text was updated successfully, but these errors were encountered: