#!/bin/sh
# the next line restarts using tclsh \
exec $GRASS_TCLSH "$0" "$@"

global env
global argv

proc usage {} {
# Print out simple Usage statement
puts "Usage:"
puts "nviz2.2 -q -help path=dir elevation=name,name,... vector=name,name,... sites=name,name,... "
}

proc help {} {
#Print Detailed help info
puts "nviz - Visualization and animation tool for GRASS data"
puts ""
puts "Usage:"
puts "nviz2.2 -q -help path=dir elevation=name vector=name sites=name path=dir"
puts ""
puts "Where:"
puts "-q Quickstart. Skip the GRASS parser and other arguments and open nviz."
puts "-h or -help Displays this message and exits"
puts "path=dir Search for additional panels in the specified directory (dir)."
puts "elevation=name,name... Use the given comma separated list of raster files."
puts "vector=name,name... Use the given comma separated list of vector files."
puts "sites=name,name... Use the given comma separated list of sites files."
puts ""
puts "For more information see the GRASS manual page for nviz2.2"
}


#CASE too many ARGS
if {$argc > 7} {
puts "Too many arguments ..."
usage
exit 
}

#CASE Help Arguments
if {($argv == "-h") || ($argv == "-help")} {
help
exit
}

#set ENV for script
set NVIZ_SCRIPTS $env(GISBASE)/etc/nviz2.2/scripts


#Execute Command
eval exec nviz -f $env(GISBASE)/etc/nviz2.2/scripts/nviz2.2_script $argv -name NVIZ >&@stdout
