[GRASS-dev] new option to set options to be required or exclusive, etc

I have three flags: i, d and c. When I use

#%rules

#%required i,d,c

#%end

and then run the script, I get the message:

Unknown option “i” in rule
Unknown option “d” in rule
Unknown option “c” in rule
ERROR: Internal error: option or flag not found

Any idea what I might be doing wrong? Using the same for options seems to work. So does this not work for flags?

On Fri, Jan 16, 2015 at 12:16 PM, Paulo van Breugel
<p.vanbreugel@gmail.com> wrote:

I have three flags: i, d and c. When I use

#%rules
#%required i,d,c

              ^^^^^^^ -- I think the colon is missing

#%end

and then run the script, I get the message:

Unknown option "i" in rule
Unknown option "d" in rule
Unknown option "c" in rule
ERROR: Internal error: option or flag not found

The manual page of g.parser describes this (the online manual will
show it in 20min from now:

http://grass.osgeo.org/grass70/manuals/g.parser.html#conditional-parameters

Markus

On Fri, Jan 16, 2015 at 12:54 PM, Markus Neteler <neteler@osgeo.org> wrote:

On Fri, Jan 16, 2015 at 12:16 PM, Paulo van Breugel
<p.vanbreugel@gmail.com> wrote:
> I have three flags: i, d and c. When I use
>
> #%rules
> #%required i,d,c
              ^^^^^^^ -- I think the colon is missing
> #%end
>

Ah, yes, I did use the colon.. this was a copy/paste from an trial to see
if I could get it to work without colon. Both do not work for me/

>
> and then run the script, I get the message:
>
> Unknown option "i" in rule
> Unknown option "d" in rule
> Unknown option "c" in rule
> ERROR: Internal error: option or flag not found

The manual page of g.parser describes this (the online manual will
show it in 20min from now:

http://grass.osgeo.org/grass70/manuals/g.parser.html#conditional-parameters

I see what I missed: the flag needs to be given with a leading "*-*":

#%rules
# %required: -i,-d,-c
#%end

It might be useful to have an example of both rules for options and for
flags (in the example section or perhaps even in the 'Conditional
parameter' section like below

For scripts, relationships are specified using a "rules" section, e.g.for
options:

  #%rules
  #%required: altitude,elevation
  #%end

and e.g., for flags:

        #%rules
  #%required: -f,-i
        #%end

p.s. note that in the help file the colon is still missing in the example
in the Conditional parameter section.

Markus

On Fri, Jan 16, 2015 at 1:16 PM, Paulo van Breugel
<p.vanbreugel@gmail.com> wrote:

I see what I missed: the flag needs to be given with a leading "-":

#%rules
# %required: -i,-d,-c
#%end

It might be useful to have an example of both rules for options and for
flags (in the example section or perhaps even in the 'Conditional parameter'
section like below

For scripts, relationships are specified using a "rules" section, e.g.for
options:

#%rules
#%required: altitude,elevation
#%end

and e.g., for flags:

#%rules
#%required: -f,-i
#%end

I have added that. The example will show up online in ~ 24hs.

p.s. note that in the help file the colon is still missing in the example in
the Conditional parameter section.

It was already fixed... as mentioned the online manual needed some
minutes to be updated.

Markus

Paulo van Breugel wrote:

It might be useful to have an example of both rules for options and for
flags (in the example section or perhaps even in the 'Conditional
parameter' section like below

For scripts, relationships are specified using a "rules" section, e.g.for
options:

  #%rules
  #%required: altitude,elevation
  #%end

and e.g., for flags:

        #%rules
  #%required: -f,-i
        #%end

It should probably have an example using both options and flags; they
can be mixed within a rule.

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