Changeset 69602


Ignore:
Timestamp:
Sep 28, 2016, 6:18:39 PM (8 years ago)
Author:
wenzeslaus
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/lib/gis/parser_help.c

    r68092 r69602  
    6565    int len, n;
    6666    int new_prompt = 0;
     67    int extensive = 0;  /* include also less important parts */
     68    int standard = 0;  /* include also standard flags */
     69    int detailed = 0;  /* details for each flag and option */
    6770
    6871    new_prompt = G__uses_new_gisprompt();
     
    7477
    7578    if (st->module_info.label || st->module_info.description) {
    76         fprintf(fp, "\n");
     79        if (extensive)
     80            fprintf(fp, "\n");
    7781        if (markers)
    7882            fprintf(fp, "{{{DESCRIPTION}}}\n");
    79         fprintf(fp, "%s\n", _("Description:"));
    80         if (st->module_info.label)
    81             fprintf(fp, " %s\n", st->module_info.label);
    82         if (st->module_info.description)
    83             fprintf(fp, " %s\n", st->module_info.description);
    84     }
    85     if (st->module_info.keywords) {
     83        if (extensive) {
     84            fprintf(fp, "%s\n", _("Description:"));
     85            if (st->module_info.label)
     86                fprintf(fp, " %s\n", st->module_info.label);
     87            if (st->module_info.description)
     88                fprintf(fp, " %s\n", st->module_info.description);
     89        }
     90        else {
     91            /* print label, if no label, try description */
     92            /* no leading space without heading */
     93            if (st->module_info.label)
     94                fprintf(fp, "%s\n", st->module_info.label);
     95            else if (st->module_info.description)
     96                fprintf(fp, "%s\n", st->module_info.description);
     97        }
     98    }
     99    if (extensive &&& st->module_info.keywords) {
    86100        fprintf(fp, "\n");
    87101        if (markers)
     
    184198            if (flag->label) {
    185199                fprintf(fp, "%s\n", flag->label);
    186                 if (flag->description)
     200                if (detailed && flag->description)
    187201                    fprintf(fp, "        %s\n", flag->description);
    188202
     
    196210    }
    197211
    198     if (new_prompt)
    199         fprintf(fp, " --o   %s\n",
    200                 _("Allow output files to overwrite existing files"));
    201 
    202     fprintf(fp, " --h   %s\n", _("Print usage summary"));
    203     fprintf(fp, " --v   %s\n", _("Verbose module output"));
    204     fprintf(fp, " --q   %s\n", _("Quiet module output"));
    205     fprintf(fp, " --qq  %s\n", _("Super quiet module output"));
    206     fprintf(fp, " --ui  %s\n", _("Force launching GUI dialog"));
    207    
     212    if (standard) {
     213        if (new_prompt)
     214            fprintf(fp, " --o   %s\n",
     215                    _("Allow output files to overwrite existing files"));
     216
     217        fprintf(fp, " --h   %s\n", _("Print usage summary"));
     218        fprintf(fp, " --v   %s\n", _("Verbose module output"));
     219        fprintf(fp, " --q   %s\n", _("Quiet module output"));
     220        fprintf(fp, " --qq  %s\n", _("Super quiet module output"));
     221        fprintf(fp, " --ui  %s\n", _("Force launching GUI dialog"));
     222    }
     223
    208224    /* Print help info for options */
    209225
     
    219235            if (opt->label) {
    220236                fprintf(fp, "%s\n", opt->label);
    221                 if (opt->description) {
     237                if (detailed && opt->description) {
    222238                    fprintf(fp, "  %*s    %s\n",
    223239                            maxlen, " ", opt->description);
     
    238254                        opt->def);
    239255
    240             if (opt->descs) {
     256            if (detailed && opt->descs) {
    241257                int i = 0;
    242258
Note: See TracChangeset for help on using the changeset viewer.