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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 28 18:18:39 PDT 2016


Author: wenzeslaus
Date: 2016-09-28 18:18:39 -0700 (Wed, 28 Sep 2016)
New Revision: 69602

Modified:
   grass/trunk/lib/gis/parser_help.c
Log:
parser: make --help shorter

By removing standard/long/common flags, making description just the label,
leaving out keywords, printing only label for flags and options
and not printing descriptions for options of an option,
the output is shorter going from 48 to 32 for r.slope.aspect
and from 72 to 43 lines for v.in.lidar.

This was done according to GRASS-dev mailing list
Adding an expert mode to the parser
https://lists.osgeo.org/pipermail/grass-dev/2016-September/082519.html


Modified: grass/trunk/lib/gis/parser_help.c
===================================================================
--- grass/trunk/lib/gis/parser_help.c	2016-09-28 23:55:37 UTC (rev 69601)
+++ grass/trunk/lib/gis/parser_help.c	2016-09-29 01:18:39 UTC (rev 69602)
@@ -64,6 +64,9 @@
     int maxlen;
     int len, n;
     int new_prompt = 0;
+    int extensive = 0;  /* include also less important parts */
+    int standard = 0;  /* include also standard flags */
+    int detailed = 0;  /* details for each flag and option */
 
     new_prompt = G__uses_new_gisprompt();
 
@@ -73,16 +76,27 @@
 	st->pgm_name = "??";
 
     if (st->module_info.label || st->module_info.description) {
-	fprintf(fp, "\n");
+        if (extensive)
+            fprintf(fp, "\n");
 	if (markers)
 	    fprintf(fp, "{{{DESCRIPTION}}}\n");
-	fprintf(fp, "%s\n", _("Description:"));
-	if (st->module_info.label)
-	    fprintf(fp, " %s\n", st->module_info.label);
-	if (st->module_info.description)
-	    fprintf(fp, " %s\n", st->module_info.description);
+        if (extensive) {
+            fprintf(fp, "%s\n", _("Description:"));
+            if (st->module_info.label)
+                fprintf(fp, " %s\n", st->module_info.label);
+            if (st->module_info.description)
+                fprintf(fp, " %s\n", st->module_info.description);
+        }
+        else {
+            /* print label, if no label, try description */
+            /* no leading space without heading */
+            if (st->module_info.label)
+                fprintf(fp, "%s\n", st->module_info.label);
+            else if (st->module_info.description)
+                fprintf(fp, "%s\n", st->module_info.description);
+        }
     }
-    if (st->module_info.keywords) {
+    if (extensive &&& st->module_info.keywords) {
 	fprintf(fp, "\n");
 	if (markers)
 	    fprintf(fp, "{{{KEYWORDS}}}\n");
@@ -183,7 +197,7 @@
 
 	    if (flag->label) {
 		fprintf(fp, "%s\n", flag->label);
-		if (flag->description)
+		if (detailed && flag->description)
 		    fprintf(fp, "        %s\n", flag->description);
 
 	    }
@@ -195,16 +209,18 @@
 	}
     }
 
-    if (new_prompt)
-	fprintf(fp, " --o   %s\n",
-		_("Allow output files to overwrite existing files"));
+    if (standard) {
+        if (new_prompt)
+            fprintf(fp, " --o   %s\n",
+                    _("Allow output files to overwrite existing files"));
 
-    fprintf(fp, " --h   %s\n", _("Print usage summary"));
-    fprintf(fp, " --v   %s\n", _("Verbose module output"));
-    fprintf(fp, " --q   %s\n", _("Quiet module output"));
-    fprintf(fp, " --qq  %s\n", _("Super quiet module output"));
-    fprintf(fp, " --ui  %s\n", _("Force launching GUI dialog"));
-    
+        fprintf(fp, " --h   %s\n", _("Print usage summary"));
+        fprintf(fp, " --v   %s\n", _("Verbose module output"));
+        fprintf(fp, " --q   %s\n", _("Quiet module output"));
+        fprintf(fp, " --qq  %s\n", _("Super quiet module output"));
+        fprintf(fp, " --ui  %s\n", _("Force launching GUI dialog"));
+    }
+
     /* Print help info for options */
 
     if (st->n_opts) {
@@ -218,7 +234,7 @@
 
 	    if (opt->label) {
 		fprintf(fp, "%s\n", opt->label);
-		if (opt->description) {
+                if (detailed && opt->description) {
 		    fprintf(fp, "  %*s    %s\n",
 			    maxlen, " ", opt->description);
 		}
@@ -237,7 +253,7 @@
 		fprintf(fp, _("  %*s   default: %s\n"), maxlen, " ",
 			opt->def);
 
-	    if (opt->descs) {
+            if (detailed && opt->descs) {
 		int i = 0;
 
 		while (opt->opts[i]) {



More information about the grass-commit mailing list