Преглед на файлове

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


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69602 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras преди 8 години
родител
ревизия
484d43ac31
променени са 1 файла, в които са добавени 35 реда и са изтрити 19 реда
  1. 35 19
      lib/gis/parser_help.c

+ 35 - 19
lib/gis/parser_help.c

@@ -64,6 +64,9 @@ static void usage(FILE *fp, int markers)
     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 @@ static void usage(FILE *fp, int markers)
 	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 @@ static void usage(FILE *fp, int markers)
 
 	    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 @@ static void usage(FILE *fp, int markers)
 	}
     }
 
-    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 @@ static void usage(FILE *fp, int markers)
 
 	    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 @@ static void usage(FILE *fp, int markers)
 		fprintf(fp, _("  %*s   default: %s\n"), maxlen, " ",
 			opt->def);
 
-	    if (opt->descs) {
+            if (detailed && opt->descs) {
 		int i = 0;
 
 		while (opt->opts[i]) {