[GRASS-SVN] r61351 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 22 16:31:10 PDT 2014


Author: annakrat
Date: 2014-07-22 16:31:10 -0700 (Tue, 22 Jul 2014)
New Revision: 61351

Modified:
   grass/trunk/lib/gis/parser.c
   grass/trunk/lib/gis/parser_dependencies.c
   grass/trunk/lib/gis/parser_local_proto.h
Log:
parser: use new option rule to launch module dialog when there is at least one option in a group specified as required

Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c	2014-07-22 22:26:17 UTC (rev 61350)
+++ grass/trunk/lib/gis/parser.c	2014-07-22 23:31:10 UTC (rev 61351)
@@ -419,7 +419,8 @@
 
     /* If there are NO arguments, go interactive */
 
-    if (argc < 2 && st->has_required && !st->no_interactive && isatty(0)) {
+    if (argc < 2 && (st->has_required || G__has_required_rule())
+        && !st->no_interactive && isatty(0)) {
 	module_gui_wx();
 	return -1;
     }

Modified: grass/trunk/lib/gis/parser_dependencies.c
===================================================================
--- grass/trunk/lib/gis/parser_dependencies.c	2014-07-22 22:26:17 UTC (rev 61350)
+++ grass/trunk/lib/gis/parser_dependencies.c	2014-07-22 23:31:10 UTC (rev 61351)
@@ -372,3 +372,21 @@
 	}
     }
 }
+
+/*!
+   \brief Checks if there is any rule RULE_REQUIRED.
+
+   \return 1 if there is such rule
+   \return 0 if not
+ */
+int G__has_required_rule(void)
+{
+    size_t i;
+
+    for (i = 0; i < rules.count; i++) {
+	const struct rule *rule = &((const struct rule *) rules.data)[i];
+	if (rule->type == RULE_REQUIRED)
+	    return TRUE;
+    }
+    return FALSE;
+}

Modified: grass/trunk/lib/gis/parser_local_proto.h
===================================================================
--- grass/trunk/lib/gis/parser_local_proto.h	2014-07-22 22:26:17 UTC (rev 61350)
+++ grass/trunk/lib/gis/parser_local_proto.h	2014-07-22 23:31:10 UTC (rev 61351)
@@ -56,6 +56,7 @@
 
 void G__check_option_rules(void);
 void G__describe_option_rules(void);
+int G__has_required_rule(void);
 
 #endif
 



More information about the grass-commit mailing list