[GRASS-dev] wxGUI: new packages layout

Glynn Clements glynn at gclements.plus.com
Fri Dec 2 08:52:28 EST 2011


Martin Landa wrote:

> > No. Pure CLI (Konsole). Modules, that fail to start, g.copy, g.rename,
> > g.remove, g.region (others too?). g.mapset, g.filename work fine. Had
> > no time to test all modules. r.* v.* and d.* modules seem to work just
> > fine.
> 
> they don't fail to start, the modules which has no required options
> (such g.remove) just do nothing. This is a feature of the parser in
> GRASS 7, this behaviour seems to be quite confusing for the user.
> 
> To force GUI dialog run
> 
> g.remove --ui

Originally, G_parser() generated the UI if a module was run with no
arguments. Individual modules had to explicitly skip the G_parser()
call if they could meaningfully be run without arguments.

However, skipping G_parser() altogether has side-effects which were
frequently overlooked, e.g. setting the program name from argv[0],
parsing opt->options into opt->opts[], parsing opt->descriptions into
opt->descs[], etc.

Consequently, a decision was made to always call G_parser(), and to
only generate a UI when no arguments are given and at least one option
is required (to do otherwise would be a nuisance for modules which can
be and often are run without options).

This falls down in the case where at least one option is required, but
not any particular option. Modules can (and should) generate an error
in this case, but currently there's no way to instruct the parser to
produce a GUI.

Well, there's no "proper" way to do this, although it would be
possible to "hack" the argc and argv which are passed to G_parser(),
e.g.:

	if (argc < 2) {
	    static char *args[3];
	    args[0] = argv[0];
	    args[1] = "--ui";
	    args[2] = NULL;
	    argv = args;
	    argc = 2;
	}
	if (G_parser(argc, argv))
	    exit(EXIT_FAILURE);

But really we need to come up with a long-term solution to the
situation where a module has requirements beyond the simplest case of
individual options being required. A solution should ideally handle
the "at least one of" case, as well as mutual exclusion and
dependencies (if A is given, B must also be given). It should also be
able to generate meaningful error messages (i.e. not just "that
combination of options is invalid").

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list