|
@@ -1,7 +1,7 @@
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
<html>
|
|
|
<head>
|
|
|
-<title>GRASS GIS manual: g.parser</title>
|
|
|
+<title>g.parser</title>
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
|
<link rel="stylesheet" href="grassdocs.css" type="text/css">
|
|
|
</head>
|
|
@@ -10,32 +10,23 @@
|
|
|
<img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
|
|
|
|
|
|
<h2>NAME</h2>
|
|
|
-<em><b>g.parser</b></em> - Provides automated parser, GUI, and help support for GRASS scipts.
|
|
|
-
|
|
|
-<h2>KEYWORDS</h2>
|
|
|
-general, support, scripts, GUI
|
|
|
+<em><b>g.parser</b></em>
|
|
|
|
|
|
<h2>SYNOPSIS</h2>
|
|
|
-<div id="name"><b>g.parser</b><br></div>
|
|
|
<b>g.parser help</b><br>
|
|
|
-<div id="synopsis"><b>g.parser</b> [-<b>st</b>] <em>filename</em> [<em>argument</em>,...]
|
|
|
-</div>
|
|
|
-
|
|
|
+<b>g.parser</b> [-<b>s</b>] [-<b>t</b>] <em>filename</em> [<em>argument</em>,...]
|
|
|
|
|
|
-<div id="flags">
|
|
|
<h3>Flags:</h3>
|
|
|
<dl>
|
|
|
<dt><b>-t</b></dt>
|
|
|
<dd>Print strings for translation</dd>
|
|
|
-
|
|
|
<dt><b>-s</b></dt>
|
|
|
<dd>Write option values to stdout instead of reinvoking script</dd>
|
|
|
</dl>
|
|
|
-</div>
|
|
|
|
|
|
<h2>DESCRIPTION</h2>
|
|
|
|
|
|
-The <em>g.parser</em> module provides full parser support for GRASS GIS
|
|
|
+The <em>g.parser</em> module provides full parser support for GRASS
|
|
|
scripts, including an auto-generated GUI interface, help page
|
|
|
template, and command line option checking. In this way a simple
|
|
|
script can very quickly be made into a full-fledged GRASS module.
|
|
@@ -52,9 +43,11 @@ header, the value will be available in variable <b>GIS_OPT_INPUT</b>
|
|
|
and the value of flag with key <b>f</b> will be available in variable
|
|
|
<b>GIS_FLAG_F</b>.
|
|
|
|
|
|
-<p>For flags, the value will be "1" if the flag was given, and "0" otherwise.
|
|
|
+<p>
|
|
|
+For flags, the value will be "1" if the flag was given, and "0" otherwise.
|
|
|
|
|
|
-<p>If the <b>-s</b> switch is used, the options and flags are written to
|
|
|
+<p>
|
|
|
+If the <b>-s</b> switch is used, the options and flags are written to
|
|
|
stdout in the form <em>opt_<name>=<value></em> and
|
|
|
<em>flag_<name>=<value></em>, preceded by the string
|
|
|
<b>@ARGS_PARSED@</b>. If this string doesn't appear as the first line
|
|
@@ -63,7 +56,8 @@ as <b>--html-description</b>. In this case, the data written by
|
|
|
<em>g.parser</em> to stdout should be copied to the script's stdout
|
|
|
verbatim.
|
|
|
|
|
|
-<p>Typical header definitions are as follows:
|
|
|
+<p>
|
|
|
+Typical header definitions are as follows:
|
|
|
|
|
|
<div class="code"><pre>
|
|
|
#%module
|
|
@@ -101,20 +95,23 @@ for opt in $GIS_OPT_INPUT ; do
|
|
|
done
|
|
|
</pre></div>
|
|
|
|
|
|
-<p>A "<tt>guisection</tt>" field may be added to each option and flag to specify
|
|
|
+<p>
|
|
|
+A "<tt>guisection</tt>" field may be added to each option and flag to specify
|
|
|
that the options should appear in multiple tabs in the auto-generated GUI.
|
|
|
Any options without a <tt>guisection</tt> field go into the "Options" tab.
|
|
|
For example:
|
|
|
<pre>#% guisection: tabname</pre>
|
|
|
would put that option in a tab named <i>tabname</i>.
|
|
|
|
|
|
-<p>A "<tt>key_desc</tt>" field may be added to each option to specify the text that
|
|
|
+<p>
|
|
|
+A "<tt>key_desc</tt>" field may be added to each option to specify the text that
|
|
|
appears in the module's usage help section. For example:
|
|
|
<pre>#% key_desc: filename</pre>
|
|
|
added to an <b>input</b> option would create the usage summary
|
|
|
<tt>[input=filename]</tt>.
|
|
|
|
|
|
-<p>If a script is run with --o, G_parser() will
|
|
|
+<p>
|
|
|
+If a script is run with --o, G_parser() will
|
|
|
set <tt>GRASS_OVERWRITE=1</tt>, which has the same effect as passing
|
|
|
--o to every module which is run from the script. Similarly, passing
|
|
|
--q or --v will set <tt>GRASS_VERBOSE</tt> to 0 or 3 respectively,
|
|
@@ -125,10 +122,6 @@ were used, you should be checking <tt>GRASS_OVERWRITE</tt> and/or
|
|
|
script should behave the same way regardless of whether they were set
|
|
|
by --o, --q or --v being passed to the script or set by other means.
|
|
|
|
|
|
-<p>In case that a GRASS module or script does not have any required
|
|
|
-options, executing the command without parameters will not open the
|
|
|
-respective parameter GUI dialog. The user can force a parameter dialog
|
|
|
-to be displayed using the --ui switch.
|
|
|
|
|
|
<h2>AUTOMATED SCRIPT CREATION</h2>
|
|
|
|
|
@@ -197,6 +190,12 @@ the build system to prepare GRASS scripts for translation.
|
|
|
|
|
|
<h2>EXAMPLES</h2>
|
|
|
|
|
|
+All examples below autogenerate the graphical user interface when invoked
|
|
|
+without parameters of flags:
|
|
|
+
|
|
|
+<p>
|
|
|
+<img src="g_parser_test.png" alt="Autogenerated GUI window">
|
|
|
+
|
|
|
<h3>Example code for SHELL</h3>
|
|
|
|
|
|
<div class="code"><pre>
|
|
@@ -260,6 +259,31 @@ echo "Value of GIS_OPT_VECTOR: '$GIS_OPT_VECTOR'"
|
|
|
|
|
|
</pre></div>
|
|
|
|
|
|
+To run properly, the script needs to be copied into $GISBASE/scripts/
|
|
|
+with the executable flag being set. The script will provide a GUI
|
|
|
+(as above) and the following usage help text:
|
|
|
+
|
|
|
+<div class="code"><pre>
|
|
|
+test.sh --help
|
|
|
+
|
|
|
+Description:
|
|
|
+ g.parser test script (python)
|
|
|
+
|
|
|
+Usage:
|
|
|
+ test.sh [-f] raster=string vector=string [option1=string]
|
|
|
+ [--verbose] [--quiet]
|
|
|
+
|
|
|
+Flags:
|
|
|
+ -f A flag
|
|
|
+ --v Verbose module output
|
|
|
+ --q Quiet module output
|
|
|
+
|
|
|
+Parameters:
|
|
|
+ raster Raster input map
|
|
|
+ vector Vector input map
|
|
|
+ option1 An option
|
|
|
+</pre></div>
|
|
|
+
|
|
|
|
|
|
<h3>Example code for Python</h3>
|
|
|
|
|
@@ -329,7 +353,8 @@ if __name__ == "__main__":
|
|
|
main()
|
|
|
</pre></div>
|
|
|
|
|
|
-The <tt>test.py</tt> script will provide following help text:
|
|
|
+The <tt>test.py</tt> script will provide a GUI (as above) and the
|
|
|
+following usage help text:
|
|
|
|
|
|
<div class="code"><pre>
|
|
|
./test.py --help
|
|
@@ -429,22 +454,21 @@ to the other examples above.
|
|
|
<h2>SEE ALSO</h2>
|
|
|
|
|
|
<em>
|
|
|
-<a href="g.filename.html">g.filename</a>,
|
|
|
-<a href="g.findfile.html">g.findfile</a>,
|
|
|
-<a href="g.tempfile.html">g.tempfile</a>,
|
|
|
+ <a href="g.filename.html">g.filename</a>,
|
|
|
+ <a href="g.findfile.html">g.findfile</a>,
|
|
|
+ <a href="g.tempfile.html">g.tempfile</a>
|
|
|
</em>
|
|
|
|
|
|
and the <tt>SUBMITTING_SCRIPTS</tt> file in the GRASS source code.
|
|
|
-<p>Related Wiki pages:
|
|
|
+<p>
|
|
|
+Related Wiki pages:
|
|
|
<a href="http://grasswiki.osgeo.org/wiki/Category:Linking_to_other_languages">Using GRASS with other programming languages</a>
|
|
|
|
|
|
<h2>AUTHOR</h2>
|
|
|
|
|
|
Glynn Clements
|
|
|
|
|
|
-<p><i>Last changed: $Date$</i>
|
|
|
-<hr>
|
|
|
-<p><a href="index.html">Main index</a> - <a href="general.html">General index</a> - <a href="topics.html">Topics index</a> - <a href="keywords.html">Keywords Index</a> - <a href="full_index.html">Full index</a></p>
|
|
|
-<p>© 2003-2013 <a href="http://grass.osgeo.org">GRASS Development Team</a>, GRASS GIS 7.0.svn Reference Manual</p>
|
|
|
+<p>
|
|
|
+<i>Last changed: $Date$</i>
|
|
|
</body>
|
|
|
</html>
|