OSGeo / grass

GRASS GIS - free and open-source geospatial processing engine
https://grass.osgeo.org
Other
849 stars 308 forks source link

[Feat] The --help flag should print to stdout, not stderr #1131

Open wenzeslaus opened 3 years ago

wenzeslaus commented 3 years ago

Is your feature request related to a problem?

In terminal, piping help into grep does nothing - it just gives whole help:

g.region --help | grep save

This is unexpected as, e.g.:

ls --help | grep context

gives:

-Z, --context   print any...

Same works for GDAL:

$ gdalinfo --help | grep json
...

It also fits with a guideline "stdout should give user what the user asked for".

Also within GRASS, module_name --script and --interface-description go to stdout, not stderr like --help.

Describe the solution you'd like

Output --help to standard output, not standard error output.

Describe alternatives you've considered

There is a workaround - redirecting the stderr to stdout, but why the modules should behave differently than other tools?

Additional context

This is similar to misuse of stderr for composing human readable outputs in #1129, but it is a separate issue.

neteler commented 3 years ago

Fully agreed, the --help flag output to stderr rather than stdout is highly confusing.

BadAssassin commented 2 years ago

Option --help-text is output to stdout. It is undocumented. I had to dig though the code to find it. It should be documented, at a minimum.