jq
jq copied to clipboard
feature: For `is not defined` error message, prompt for similar names
Current outputs:
$ jq -n 'to_string'
jq: error: to_string/0 is not defined at <top-level>, line 1:
to_string
jq: 1 compile error
$ jq -n '1 as $X | $x'
jq: error: $x is not defined at <top-level>, line 1:
1 as $X | $x
jq: 1 compile error
Expect outputs like:
$ jq -n 'to_string'
jq: error: to_string/0 is not defined at <top-level>, line 1:
to_string
jq: Did you mean: tostring/0?
jq: 1 compile error
$ jq -n '1 as $X | $x'
jq: error: $x is not defined at <top-level>, line 1:
1 as $X | $x
jq: Did you mean: $X?
jq: 1 compile error
Similar python:
$ python
Python 3.12.7 (main, Oct 11 2024, 10:50:28) [GCC 14.1.1 20240507] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> X=2
>>> x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined. Did you mean: 'X'?
>>> priny
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'priny' is not defined. Did you mean: 'print'?
Levenshtein distance? Yes, apparently that's how Python does. https://github.com/python/cpython/blob/v3.13.0/Python/suggestions.c#L164-L166