[GRASS-dev] d.redraw -> g.parser

Glynn Clements glynn at gclements.plus.com
Wed Nov 8 07:38:14 EST 2006


Hamish wrote:

> currently d.redraw doesn't use the parser as it takes no options.
> 
> For man pages, etc it is nice to use it.
> 
> There is --ui to force the GUI in parser.c, but no --no-ui to avoid it.
> And no enviro vars to control this either, AFAICT.

What would --no-ui achieve?

The GUI dialog should only be generated if you don't pass any
arguments but the program has at least one required argument.

However, currently it's up to the module to implement this. Modules
which can be run without arguments should skip calling G_parser() if
no arguments are given, e.g.:

	if (argc > 1 && G_parser(argc, argv))
		exit(1);

If necessary, this could be added to G_parser(); relying upon the
module to do it saves G_parser() from having to determine whether
there are any required arguments.

Apart from that, the only use for a --no-ui switch which I can see is
to force an error message (rather than a dialog) when one or more
arguments are required but none are given.

Or am I missing something?

> Any problem with adding the --q flag to get the same effect?

--q is for the user. If the user doesn't use --q, they presumably want
their normal verbosity settings to be honoured.

> -#GUI is not very useful here, commented:
> -#if [ "$1" != "@ARGS_PARSED@" ] ; then
> -#  exec g.parser "$0" "$@"
> -#fi
> +#GUI is not very useful here,
> +if [ "$1" != "@ARGS_PARSED@" ] ; then
> +  exec g.parser "$0" "$@" --q
> +fi

If you want an error message instead of a GUI when no arguments are
given, you could use:

if [ "$1" != "@ARGS_PARSED@" ] ; then
  if [ "$#" = 0 ] ; then
    exec g.parser "$0" "$@" --q
  else
    exec g.parser "$0" "$@"
  fi
fi

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




More information about the grass-dev mailing list