[GRASS-SVN] r45188 - grass/trunk/general/g.version

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 26 05:44:29 EST 2011


Author: martinl
Date: 2011-01-26 02:44:29 -0800 (Wed, 26 Jan 2011)
New Revision: 45188

Modified:
   grass/trunk/general/g.version/g.version.html
   grass/trunk/general/g.version/main.c
Log:
g.version: shell flag introduced + manual updated


Modified: grass/trunk/general/g.version/g.version.html
===================================================================
--- grass/trunk/general/g.version/g.version.html	2011-01-26 10:02:44 UTC (rev 45187)
+++ grass/trunk/general/g.version/g.version.html	2011-01-26 10:44:29 UTC (rev 45188)
@@ -1,18 +1,56 @@
-<H2>DESCRIPTION</H2>
+<h2>DESCRIPTION</h2>
 
-<EM>g.version</EM>
-prints to standard output the GRASS version number, date,
-the GRASS copyright and GRASS build information.
+<em>g.version</em> prints to standard output the GRASS version number,
+date, the GRASS copyright and GRASS build information.
 
-<H2>NOTES</H2>
+<h2>NOTES</h2>
 
-This program requires no command line arguments; the user simply types 
-<B>g.version</B> on the command line to see the version number and date 
-of the GRASS software currently being run by the user. 
+This program requires no command line arguments; the user simply types
+<em>g.version</em> on the command line to see the version number and
+date of the GRASS software currently being run by the user.
 
-<H2>AUTHOR</H2>
+<h2>EXAMPLES</h2>
 
+<div class="code"><pre>
+g.version 
+
+GRASS 7.0.svn45136 (2011)
+</pre></div>
+
+<div class="code"><pre>
+g.version -r
+
+GRASS 7.0.svn45136 (2011)
+Revision: 45093 
+Date: 2011-01-20 13:10:50 +0100 (Thu, 20 Jan 2011)
+</pre></div>
+
+<div class="code"><pre>
+g.version -rg
+
+version=7.0.svn
+revision=45136
+date=2011
+gis_revision=Revision: 45093 
+gis_date=Date: 2011-01-20 13:10:50 +0100 (Thu, 20 Jan 2011) 
+</pre></div>
+
+<h2>PYTHON</h2>
+
+See <em><a href="http://grass.osgeo.org/programming7/pythonlib.html">Python
+Scripting Library</a></em> for more info.
+
+<div class="code"><pre>
+import grass.script as grass
+
+grass.version()
+</div>
+
+<h2>AUTHOR</h2>
+
 Michael Shapiro, 
 U.S. Army Construction Engineering 
 Research Laboratory
-<p><i>Last changed: $Date$</i>
+
+<p>
+<i>Last changed: $Date$</i>

Modified: grass/trunk/general/g.version/main.c
===================================================================
--- grass/trunk/general/g.version/main.c	2011-01-26 10:02:44 UTC (rev 45187)
+++ grass/trunk/general/g.version/main.c	2011-01-26 10:44:29 UTC (rev 45188)
@@ -7,7 +7,7 @@
 *  	    	Justin Hickey - Thailand - jhickey hpcc.nectec.or.th
 * PURPOSE: 	Output GRASS version number, date and copyright message.
 *             
-* COPYRIGHT:  	(C) 2000-2009 by the GRASS Development Team
+* COPYRIGHT:  	(C) 2000-2009, 2011 by the GRASS Development Team
 *
 *   	    	This program is free software under the GPL (>=v2)
 *   	    	Read the file COPYING that comes with GRASS for details.
@@ -35,33 +35,45 @@
 int main(int argc, char *argv[])
 {
     struct GModule *module;
-    struct Flag *copyright, *build, *gish_rev;
+    struct Flag *copyright, *build, *gish_rev, *shell;
 
     G_gisinit(argv[0]);
 
     module = G_define_module();
     G_add_keyword(_("general"));
+    G_add_keyword(_("version"));
     module->description = _("Displays version and copyright information.");
 
     copyright = G_define_flag();
     copyright->key = 'c';
-    copyright->description = _("Print the copyright message");
+    copyright->description = _("Print also the copyright message");
 
     build = G_define_flag();
     build->key = 'b';
-    build->description = _("Print the GRASS build information");
+    build->description = _("Print also the GRASS build information");
 
     gish_rev = G_define_flag();
     gish_rev->key = 'r';
     gish_rev->description =
-	_("Print the GIS library revision number and time");
+	_("Print also the GIS library revision number and time");
 
+    shell = G_define_flag();
+    shell->key = 'g';
+    shell->description = _("Print info in shell script style");
+    
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    fprintf(stdout, "GRASS %s%s (%s)\n",
-	    GRASS_VERSION_NUMBER, GRASS_VERSION_SVN,
-	    GRASS_VERSION_DATE);
+    if (shell->answer) {
+	fprintf(stdout, "version=%s\n", GRASS_VERSION_NUMBER);
+	fprintf(stdout, "revision=%s\n", GRASS_VERSION_SVN);
+	fprintf(stdout, "date=%s\n", GRASS_VERSION_DATE);
+    }
+    else {
+	fprintf(stdout, "GRASS %s%s (%s)\n",
+		GRASS_VERSION_NUMBER, GRASS_VERSION_SVN,
+		GRASS_VERSION_DATE);
+    }
     
     if (copyright->answer) {
 	fprintf(stdout, "\n");
@@ -78,7 +90,13 @@
 	/* fprintf(stdout, "%s\n%s\n", GIS_H_VERSION, GIS_H_DATE); */
 	char **rev_ver = G_tokenize(GIS_H_VERSION, "$");
 	char **rev_time = G_tokenize(GIS_H_DATE, "$");
-	fprintf(stdout, "%s\n%s\n", rev_ver[1], rev_time[1]);
+	if (shell->answer) {
+	    fprintf(stdout, "gis_revision=%s\n", rev_ver[1]);
+	    fprintf(stdout, "gis_date=%s\n", rev_time[1]);
+	}
+	else {
+	    fprintf(stdout, "%s\n%s\n", rev_ver[1], rev_time[1]);
+	}
 	G_free_tokens(rev_ver);
 	G_free_tokens(rev_time);
     }



More information about the grass-commit mailing list