#!/bin/sh ############################################################################ # # MODULE: g.manual # AUTHOR(S): Markus Neteler # PURPOSE: Display the HTML/MAN pages # COPYRIGHT: (C) 2003 by the GRASS Development Team # # This program is free software under the GNU General Public # License (>=v2). Read the file COPYING that comes with GRASS # for details. # ############################################################################# #%Module #% description: display the HTML man pages of GRASS #% keywords: general, manual, help #%End #%flag #% key: i #% description: display index #%END #%flag #% key: m #% description: display as MAN text page instead of HTML page in browser #%END #%option #% key: entry #% type: string #% description: manual entry to be displayed #% required : no #%END GRASS_DOC_BASE="$GISBASE" if [ "$1" != "@ARGS_PARSED@" ] ; then exec g.parser "$0" "$@" fi #hack for MacOSX: if [ "$HOSTTYPE" = "macintosh" ] ; then BROWSERNAME="default Macintosh web browser" #hack for Cygwin: elif [ "$OSTYPE" = "cygwin" ] ; then for i in C D E F G H I J K L M N O P Q R S T U V W X Y Z NOT_FOUND do j="$i:$CYGWIN_ROOT$GRASS_DOC_BASE" if [ -f "$j"/docs/html/index.html ] ; then GRASS_DOC_BASE=$j break fi done if [ "$i" = "NOT_FOUND" ] ; then echo "ERROR: cannot find grass document base." exit 1 fi BROWSERNAME=`basename "$GRASS_HTML_BROWSER" | sed 's/\.exe$//i'` else BROWSERNAME="$GRASS_HTML_BROWSER" fi start_browser() { if test ! -f "$GRASS_DOC_BASE"/docs/html/$1.html -a -n $1 ; then echo "ERROR: no HTML manual page entry for <$1>." exit 1 else echo "Starting browser <$BROWSERNAME> for module $1..." "$GRASS_HTML_BROWSER" file://"$GRASS_DOC_BASE"/docs/html/$1.html fi } start_man() { if test ! -f "$GRASS_DOC_BASE"/man/man1/$1.1 -a -n $1 ; then echo "ERROR: no MAN page entry for <$1>." exit 1 else man "$GRASS_DOC_BASE"/man/man1/$1.1 fi } #keep order! #first test for index... if [ $GIS_FLAG_I -eq 1 ] ; then if [ $GIS_FLAG_M -eq 1 ] ; then start_man index exit 0 else start_browser index exit 0 fi fi #... then for help parameter: if [ -z "$GIS_OPT_ENTRY" ] ; then g.manual help exit 0 fi if [ $GIS_FLAG_M -eq 1 ] ; then start_man "$GIS_OPT_ENTRY" else start_browser "$GIS_OPT_ENTRY" fi exit 0