Re: Option parser



On fre, 2004-07-30 at 02:57 -0400, Havoc Pennington wrote:
> On Thu, 2004-07-29 at 16:21, Anders Carlsson wrote:
> > 
> > The API is attached, I welcome any comments or suggestions.
> > 
> 
> One thought that came up on dbus list, is that in almost all GUI apps
> you have two cases:
>  - the app is the first instance and uses the command line options
>    directly
>  - the app is a second instance and forwards the options and 
>    args to the first instance
> 
> It might be interesting if the option parsing API made this easy.
> gtk_init() for example isn't really a good API for this.
> 
> gnome-terminal demonstrates the kind of mess you can get into...
> 
> Not sure what is involved in addressing this, but ability to parse
> options separately from unrelated steps such as initialization seems
> like part of it.
> 

One idea Matthias Clasen came up with was to add a G_OPTION_FLAG_IGNORE.
Option entries flagged with that would be shown in --help, but wouldn't
be NULLed out the corresponding argv strings.

I suppose you could do something like this in that case:

context = g_option_context_new ();
gtk_add_option_group (context);
g_poption_context_parse (context, &argc, &argv);
...
/* Handle forwarding of options */
...
gtk_init (&argc, &argv);

(With the gtk option group having all entries flagged to be ignored).
Maybe we could add a FORWARD flag for entries that should be forwarded
to another application, I'm not sure.

Anders




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