dfhack icon indicating copy to clipboard operation
dfhack copied to clipboard

Scripts: [arg parse] incorrect option, suggestion (did you mean __?)

Open cppcooper opened this issue 1 year ago • 0 comments

Since we control the implementation of the lua argument parser, we should seriously consider adding a mechanism to suggest corrections if what the user typed was invalid.

Example:

[DFHack]# devel/query --table df --depth 2
devel/query: error: invalid arg: 3: depth
Did you mean --maxdepth?

An idea for implementation by @myk002 is to use a "letter frequency map and suggest the option names that have the most overlap".

An alternative idea, but in the same spirit, could be to implement a dot product as one might see in NLP when comparing documents' similarity, or sentences, or [of course] single words.

Yet one more is just to take what the user typed and do a much dumber check. Wherein we just search for the input as a substring in any of the valid args we know about.

cppcooper avatar Sep 18 '22 03:09 cppcooper