#!/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,dig,vector #% description: vector input map #% required : yes #%end #%option #% key: option1 #% type: string #% description: an option #% required : no #%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
The test.sh script will provide following help text:
./test.sh --help Description: g.parser test script Usage: test.sh [-f] option=name Flags: -f a flag Parameters: option an option
#% multiple : yesWhile this will only directly change the Usage 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:
IFS=, for opt in $GIS_OPT_input ; do ... "$opt" done
Last changed: $Date: 2004/04/19 08:05:27 $