git-svn-id: https://svn.osgeo.org/grass/grass/trunk@61351 15284696-431f-4ddb-bdfa-cd5b030d7da7
@@ -419,7 +419,8 @@ int G_parser(int argc, char **argv)
/* 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;
}
@@ -372,3 +372,21 @@ void G__describe_option_rules(void)
+
+/*!
+ \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;
+}
@@ -56,6 +56,7 @@ void G__print_keywords(FILE *, void (*)(FILE *, const char *));
void G__check_option_rules(void);
void G__describe_option_rules(void);
+int G__has_required_rule(void);
#endif