[GRASS-SVN] r45190 - grass/branches/develbranch_6/general/g.version
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jan 26 05:57:12 EST 2011
Author: martinl
Date: 2011-01-26 02:57:12 -0800 (Wed, 26 Jan 2011)
New Revision: 45190
Modified:
grass/branches/develbranch_6/general/g.version/main.c
Log:
g.version: shell style output
Modified: grass/branches/develbranch_6/general/g.version/main.c
===================================================================
--- grass/branches/develbranch_6/general/g.version/main.c 2011-01-26 10:48:02 UTC (rev 45189)
+++ grass/branches/develbranch_6/general/g.version/main.c 2011-01-26 10:57:12 UTC (rev 45190)
@@ -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.
@@ -34,35 +34,44 @@
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();
- module->keywords = _("general");
+ module->keywords = _("general, 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 (argc > 1 && G_parser(argc, argv))
exit(EXIT_FAILURE);
-
- fprintf(stdout, "GRASS %s (%s) %s\n",
- GRASS_VERSION_NUMBER, GRASS_VERSION_DATE,
- GRASS_VERSION_UPDATE_PKG);
-
+ if (shell->answer) {
+ fprintf(stdout, "version=%s\n", GRASS_VERSION_NUMBER);
+ fprintf(stdout, "date=%s\n", GRASS_VERSION_DATE);
+ }
+ else {
+ fprintf(stdout, "GRASS %s (%s) %s\n",
+ GRASS_VERSION_NUMBER, GRASS_VERSION_DATE,
+ GRASS_VERSION_UPDATE_PKG);
+ }
+
if (copyright->answer) {
fprintf(stdout, "\n");
fputs(COPYING, stdout);
@@ -75,10 +84,15 @@
}
if (gish_rev->answer) {
- /* 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