Ver código fonte

g.parser manual: added Glynn's notes about conditional rules from http://lists.osgeo.org/pipermail/grass-dev/2014-November/071916.html

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@64180 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 10 anos atrás
pai
commit
e0384b6044
1 arquivos alterados com 45 adições e 1 exclusões
  1. 45 1
      general/g.parser/g.parser.html

+ 45 - 1
general/g.parser/g.parser.html

@@ -112,7 +112,8 @@ The syntax of the rules section is following:
 #%end
 </pre></div>
 
-The parser also allows to define "OR" conditions, e.g. requiring raster OR vector:
+The parser also allows to define "OR" conditions, e.g. requiring raster
+OR vector (for details, see below):
 
 <div class="code"><pre>
 #%rules
@@ -165,6 +166,49 @@ should behave the same way regardless of whether they were set
 by <b>--o</b>, <b>--q</b> or <b>--v</b> being passed to the script or
 set by other means.
 
+<h2>Conditional parameters</h2>
+
+Marking an option as "required" will result in the parser raising a
+fatal error if the option is not given, with one exception: if a flag
+has the <tt>suppress_required</tt> option, and that flag is given, all
+requirements are ignored. This feature is intended for flags which
+abandon "normal operation" for the module; e.g. <em>r.in.gdal</em>'s
+<b>-f</b> flag (list supported formats) uses it.
+<br>
+But in general, an option cannot be marked as required if it is
+optional except for the special case of a <tt>suppress_required</tt> flag.
+The parser has the ability to specify option relationships.
+
+<p>
+For C, the relevant functions are those in
+<a href="http://grass.osgeo.org/programming7/parser__dependencies_8c.html">lib/gis/parser_dependencies.c</a>.
+
+<p>
+For scripts, relationships are specified using a "rules" section, e.g.
+
+<div class="code"><pre>
+	#%rules
+	#%required altitude,elevation
+	#%end
+</pre></div>
+
+specifies that at least one of those options must be given. Both
+options and flags can be specified (a leading "<b>-</b>" denotes a flag).
+
+The available rule types are:
+
+<ul>
+<li> <tt>exclusive</tt>: at most one of the options may be given</li>
+<li> <tt>required</tt>: at least one of the options must be given</li>
+<li> <tt>requires</tt>: if the first option is given, at least one of the
+      subsequent options must also be given</li>
+<li> <tt>requires_all</tt>: if the first option is given, all of the
+      subsequent options must also be given</li>
+<li> <tt>excludes</tt>: if the first option is given, none of the
+      subsequent options may be given</li>
+<li> <tt>collective</tt>: all or nothing; if any option is given, all
+      must be given</li>
+</ul>
 
 <h2>AUTOMATED SCRIPT CREATION</h2>