File: description.html

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (125 lines) | stat: -rw-r--r-- 2,402 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>g.parser</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="white">

<h2>NAME</h2>
<em><b>g.parser</b></em>

<H2>DESCRIPTION</H2>

The command provides full parser support for GRASS scripts.
<P>

<H2>OPTIONS</H2>

The arguments are stored in environment variables, named
GIS_FLAG_&lt;name&gt; for flags and GIS_OPT_&lt;name&gt; for options.
 
For flags, the value will be "1" if the flag was given, and "0"
otherwise.
<P>

<pre>
#!/bin/sh

# g.parser demo script

#%Module
#%  description: g.parser test script   
#%End
#%flag
#%  key: f
#%  description: a flag
#%END
#%option
#% key: raster
#% type: string
#% gisprompt: old,cell,raster
#% description: raster input map
#% required : yes
#%end
#%option
#% key: vector
#% type: string
#% gisprompt: old,vector,vector
#% description: vector input map
#% required : yes
#%end
#%option
#% key: option1
#% type: string
#% description: an option
#% required : yes
#%end

if [ "$1" != "@ARGS_PARSED@" ] ; then
  exec $GISBASE/etc/bin/cmd/g.parser "$0" "$@"
fi

#add your code here
echo ""
if [ $GIS_FLAG_f -eq 1 ] ; then
  echo "Flag -f set"
else
  echo "Flag -f not set"
fi

#test if parameter present:
if [ "$GIS_OPT_option1" != "(null)" ] ; then
  echo "Value of GIS_OPT_option1: '$GIS_OPT_option1'"
fi

echo "Value of GIS_OPT_raster: '$GIS_OPT_raster'"
echo "Value of GIS_OPT_vect: '$GIS_OPT_vector'"

#add your code here
</pre>

<P>
The <tt>test.sh</tt> script will provide following help text:
<P>
<pre>
./test.sh --help

Description:
 g.parser test script
 
Usage:
 test.sh [-f] option=name
 
Flags:
  -f   a flag
 
Parameters:
  option   an option
</pre>

<H2>NOTES</H2>

An option can be instructed to allow multiple inputs by adding the following line:
<pre>#% multiple : yes</pre>
While this will only directly change the <i>Usage</i> section of the help
screen, the option's environmental string may be easily parsed from within
a script. For example, individual comma separated identities for an option 
named "input" can be parsed with the following Bash shell code:

<pre>IFS=,
for opt in $GIS_OPT_input ; do
	... "$opt"
done
</pre>

<H2>SEE ALSO</H2>

<EM><A HREF="g.findfile.html">g.findfile</A></EM>

<H2>AUTHOR</H2>

Glynn Clements
<p><i>Last changed: $Date: 2004/11/05 11:28:18 $</i>
</body>
</html>