GOption extension



Hi,

I've just found the replacement for popt is introduced to glib.
I have some proposals to GOption extension.

1. Replacement for help print function
2. Type extension


1. Replacement for help print function

In current implementation, the function for --help is 
statically defined. I think it is nice if I can replace
it at runtime. Example:

[jet localhost glib]$ pkg-config --help
Usage: pkg-config [OPTION...]
  --version                                      output version of pkg-config
  --modversion                                   output version for package
  --atleast-pkgconfig-version=VERSION            require given version of
  ...

[jet localhost glib]$ export GTK_MODULES=install-xml-help
[jet localhost glib]$ pkg-config --help
<GOptionUsage command="pkg-config"> 
	<option long-name="version" argument="NONE"/>
	<option long-name="modversion" argument=="NONE"/>
	<option long-name="atleast-pkgconfig-version" argument=="STRING" argument-name="VERSION"/>
	...
</GOptionUsage>

In this example, the print function is replaced by install-xml-help module.
The newly introduced print function prints the help message in XML format.
The XML formatted help message will be useful to generate GUI for the 
target command automatically; and to generate zsh completion rules
automatically.


2. Type extension

GOptionArg supports only following types.
    typedef enum
    {
      G_OPTION_ARG_NONE,
      G_OPTION_ARG_STRING,
      G_OPTION_ARG_INT,
      G_OPTION_ARG_CALLBACK,
      G_OPTION_ARG_FILENAME,
      G_OPTION_ARG_STRING_ARRAY,
      G_OPTION_ARG_FILENAME_ARRAY
    } GOptionArg;


I think it is nice to extend these types.  So the automatically
generated GUI or completion rules can use the type information.
e.g. hostname, installed package name, etc.

Regards,
Masatake YAMATO



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