gem / oq-engine

OpenQuake Engine: a software for Seismic Hazard and Risk Analysis
https://github.com/gem/oq-engine/#openquake-engine
GNU Affero General Public License v3.0
387 stars 277 forks source link

Error messages for wrong command lines are not ideal #2104

Closed micheles closed 7 years ago

micheles commented 8 years ago

For instance

$ oq engine --foo
usage: oq [-v]
                   {dbserver,info,purge,show,show_attrs,upgrade_nrml,tidy,plot_sites,plot,run,reduce,export,engine,help}
                   ...
oq: error: unrecognized arguments: --foo

we get the error for oq not for oq engine. It is not clear if this can be solved, since it looks like an issue of argparse.

micheles commented 7 years ago

It is not worth spending time for this. It also probably very difficult.

raoanirudh commented 7 years ago

For reference, git uses the Damerau-Levenshtein algorithm to suggest alternatives for mistyped commands. See also the functions help_unknown_cmd(...) and help_unknown_ref(...) in https://github.com/git/git/blob/master/help.c for git's solution to this issue.

micheles commented 7 years ago

We can do that in Python, there are libraries for smart autocompletion. The problem is that I do not want to abandon argparse which is in the standard library. Also, I do not think it is worth the effort, given that the direction we are going is towards a Web/QGIS interface. The command-line will be left for power users who know what they are doing,