Skip to content
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

Papercuts in handle_local_options's return parameter #1592

Open
A6GibKm opened this issue Dec 9, 2024 · 2 comments
Open

Papercuts in handle_local_options's return parameter #1592

A6GibKm opened this issue Dec 9, 2024 · 2 comments

Comments

@A6GibKm
Copy link
Contributor

A6GibKm commented Dec 9, 2024

The virtual method handle_local_options returns a glib::ExitCode, it is special cased so that the application exits when the return value is positive (e.g. ExitCode::FAILUE, ExitCode::SUCCESS) and continues to run when when negative.

Returning (-1).into() is an option, but it is not very nice.

@sdroege
Copy link
Member

sdroege commented Dec 9, 2024

@A6GibKm Want to provide a PR for this? Docs say this:

   * Returns: an exit code. If you have handled your options and want
   * to exit the process, return a non-negative option, 0 for success,
   * and a positive value for failure. To continue, return -1 to let
   * the default option processing continue.

Now this just needs to be wrapped into meaningful types. All negative values are the same (default processing), 0 is success but no default processing, all values > 0 are errors and returned like that

@A6GibKm
Copy link
Contributor Author

A6GibKm commented Dec 9, 2024

What I dont follow is when it is actually a return code? I will test later if 0 is a return code.

It could be an enum

LocalOptionsHandling {
    ExitCode(glib::ExitCode),  //  >= 0
    DefaultProcessing,  // -1
}

or something like that.

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

No branches or pull requests

2 participants