Re: GOption & friends



Le 21/03/2011 15:26, John Coppens a écrit :
Hello people,

Hi you,

I've been trying to get GOption and friends working - but it seems
we're not on friendly terms.

1) I defined a GOptionEntry as:

{"debug", 'd', 0, G_OPTION_ARG_STRING, &dbg, "Debug options", "opts"},

and find that
  -d e       works
  --debug e
  --debug=e  work correctly

  -de        gives "option parsing failed: Missing argument for -d"

The form (-de), frequently used, fails though it is advertised
in the Command line parser description:

http://library.gnome.org/devel/glib/unstable/glib-Commandline-option-parser.html#g-option-context-add-main-entries

why?

This is NOT meant to work as you seem to expect, and the docs tells you:
"-de" is the same as "-d -e", not "-d e".
This is a very common thing, and most commands works this way (apart
perhaps cut).

2) The above entry should have a list of the actual debug options,
but I haven't found a practical way to add them to the help text.
I'd like to add options like:

  p: debug printing
  l: debug logging

Actually, I've extended the "Debug options" string with \n's and
looong string, but there should be a more practical way... is there?

No idea, sorry.

3) The reason I wanted to migrate to GOption, is that it seems
gnome_program_init doesn't eliminate the recognized default arguments
such as --g-fatal-warnings, if added. So, in gdb, a run
--g-fatal-warnings produces an error in getopt. 

AFAIR, --g-fatal-warnings is NOT a standard option. You're expected to
use the environment variable G_DEBUG:
G_DEBUG=fatal-warnings gdb yourapp

See http://library.gnome.org/devel/glib/unstable/glib-running.html

I've looked through numerous pages - can anyone point to an app that
actually uses GOption for more than a minimal options set?

Most GNOME programs, and let's guess: GIMP ;)

Regards,
Colomban



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]