1
1
mirror of https://github.com/wader/fq.git synced 2024-09-11 20:07:11 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Mattias Wadman
64eae8730f
Merge f8f4473afd into e1da76df6c 2024-02-12 17:03:23 +01:00
Mattias Wadman
f8f4473afd repl: A bit nicer array completion 2023-05-13 21:39:56 +02:00

View File

@ -52,9 +52,10 @@ def _complete($line; $cursor_pos):
def _is_separator: . as $c | " .;[]()|=" | contains($c);
def _is_internal: startswith("_") or startswith("$_");
def _query_index_or_key($q):
( ([.[] | _eval($q; {}) | type]) as $n
| if ($n | all(. == "object")) then "."
elif ($n | all(. == "array")) then "[]"
( ([.[] | _eval($q; {}) | type])
| if length > 0 and all(. == "object") then "."
# TODO: only [] if not first [1,2,3]\t -> [][] not [].[]
elif length > 0 and all(. == "array") then ".[]"
else null
end
);