[GRASS-dev] d.redraw -> g.parser
Hamish
hamish_nospam at yahoo.com
Mon Nov 13 00:27:22 EST 2006
Glynn Clements wrote:
>
> 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 same as GRASS_UI_TERM=1
> 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?
I am talking about shell scripts that normally take no arguments:
d.redraw (GUI + [Run] is not desired)
v.build.all, v.convert.all, v.in.sites.all
(GUI+[Run] would be ok IF --ui was given [but must function without tcltk])
for the last three, --q is probably a good idea.
right now they bypass g.parser most of the time:
if [ $# -eq 0 ] || [ $1 = "-h" -o $1 = "help" -o $1 = "-help" -o $1 = "--help" ] ; then
if [ "$1" != "@ARGS_PARSED@" ] ; then
exec g.parser "$0" "$@"
fi
fi
We could add '-o $1 = "--html-description"', xml, tcl, ui, --q, --v, to
that list, but it seems a bad solution. Removing that line and running
with no args,
G63> GRASS_UI_TERM=1 d.redraw
Programmer error: no flags or options
> > 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
I want the modules to run when no args are passed, but use G_parser()
otherwise. so maybe just:
if [ "$#" -gt 0 ] ; then
exec g.parser "$0" "$@"
fi
what's contained in "@ARGS_PARSED@"?
Hamish
More information about the grass-dev
mailing list