[GRASS-SVN] r32595 - grass/trunk/raster/r.colors

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 6 21:29:16 EDT 2008


Author: glynn
Date: 2008-08-06 21:29:16 -0400 (Wed, 06 Aug 2008)
New Revision: 32595

Modified:
   grass/trunk/raster/r.colors/main.c
Log:
Remove -i flag, use rules=- to read rules from stdin


Modified: grass/trunk/raster/r.colors/main.c
===================================================================
--- grass/trunk/raster/r.colors/main.c	2008-08-07 00:08:04 UTC (rev 32594)
+++ grass/trunk/raster/r.colors/main.c	2008-08-07 01:29:16 UTC (rev 32595)
@@ -111,7 +111,7 @@
     struct GModule *module;
     struct
     {
-	struct Flag *r, *w, *l, *g, *e, *i, *n;
+	struct Flag *r, *w, *l, *g, *e, *n;
     } flag;
     struct
     {
@@ -131,6 +131,20 @@
     opt.map->required = NO;
     opt.map->guisection = _("Required");
 
+    opt.rast = G_define_option();
+    opt.rast->key = "raster";
+    opt.rast->type = TYPE_STRING;
+    opt.rast->required = NO;
+    opt.rast->gisprompt = "old,cell,raster";
+    opt.rast->description =
+	_("Raster map name from which to copy color table");
+
+    opt.rules = G_define_standard_option(G_OPT_F_INPUT);
+    opt.rules->key = "rules";
+    opt.rules->required = NO;
+    opt.rules->description = _("Path to rules file (\"-\" to read rules from stdin)");
+    opt.rules->guisection = _("Colors");
+
     scan_rules();
 
     opt.colr = G_define_option();
@@ -171,20 +185,6 @@
 	  "wave;color wave;");
     opt.colr->guisection = _("Colors");
 
-    opt.rast = G_define_option();
-    opt.rast->key = "raster";
-    opt.rast->type = TYPE_STRING;
-    opt.rast->required = NO;
-    opt.rast->gisprompt = "old,cell,raster";
-    opt.rast->description =
-	_("Raster map name from which to copy color table");
-
-    opt.rules = G_define_standard_option(G_OPT_F_INPUT);
-    opt.rules->key = "rules";
-    opt.rules->required = NO;
-    opt.rules->description = _("Path to rules file");
-    opt.rules->guisection = _("Colors");
-
     flag.r = G_define_flag();
     flag.r->key = 'r';
     flag.r->description = _("Remove existing color table");
@@ -213,10 +213,6 @@
     flag.e->description = _("Histogram equalization");
     flag.e->guisection = _("Colors");
 
-    flag.i = G_define_flag();
-    flag.i->key = 'i';
-    flag.i->description = _("Enter rules interactively");
-
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -226,7 +222,6 @@
     }
 
     overwrite = !flag.w->answer;
-    interactive = flag.i->answer;
     remove = flag.r->answer;
 
     name = opt.map->answer;
@@ -238,15 +233,15 @@
     if (!name)
 	G_fatal_error(_("No map specified"));
 
-    if (!cmap && !style && !rules && !interactive && !remove)
-	G_fatal_error(_("One of \"-i\" or \"-r\" or options \"color\", \"rast\" or \"rules\" must be specified!"));
+    if (!cmap && !style && !rules && !remove)
+	G_fatal_error(_("One of \"-r\" or options \"color\", \"rast\" or \"rules\" must be specified!"));
 
-    if (interactive && (style || rules || cmap))
-	G_fatal_error(_("Interactive mode is incompatible with \"color\", \"rules\", and \"raster\" options"));
-
-    if ((style && (cmap || rules)) || (cmap && rules))
+    if (!!style + !!cmap + !!rules != 1)
 	G_fatal_error(_("\"color\", \"rules\", and \"raster\" options are mutually exclusive"));
 
+    interactive = strcmp(rules, "-") == 0;
+    if (interactive)
+	rules = NULL;
 
     mapset = G_find_cell2(name, "");
     if (mapset == NULL)



More information about the grass-commit mailing list