mirror of
https://github.com/wader/fq.git
synced 2024-12-29 00:22:38 +03:00
Merge pull request #179 from wader/bump-gojq-tonumber-try
gojq: Rebase fq fork and add support for non-10 base for tonumber
This commit is contained in:
commit
a0b32dd57a
12
go.mod
12
go.mod
@ -4,12 +4,16 @@ go 1.17
|
||||
|
||||
require (
|
||||
// fork of github.com/itchyny/gojq, see github.com/wader/gojq fq branch
|
||||
github.com/wader/gojq v0.12.1-0.20220212115358-b98ce15ac16e
|
||||
github.com/wader/gojq v0.12.1-0.20220302110453-379a885caece
|
||||
// fork of github.com/chzyer/readline, see github.com/wader/readline fq branch
|
||||
github.com/wader/readline v0.0.0-20220117233529-692d84ca36e2
|
||||
)
|
||||
|
||||
require (
|
||||
// bump: gomod-golang-snappy /github.com\/golang\/snappy v(.*)/ https://github.com/golang/snappy.git|^0
|
||||
// bump: gomod-golang-snappy command go get -d github.com/golang/snappy@v$LATEST && go mod tidy
|
||||
// bump: gomod-golang-snappy link "Source diff $CURRENT..$LATEST" https://github.com/golang/snappy/compare/v$CURRENT..v$LATEST
|
||||
github.com/golang/snappy v0.0.4
|
||||
// bump: gomod-gopacket /github\.com\/google\/gopacket v(.*)/ https://github.com/google/gopacket.git|^1
|
||||
// bump: gomod-gopacket command go get -d github.com/google/gopacket@v$LATEST && go mod tidy
|
||||
// bump: gomod-gopacket link "Release notes" https://github.com/google/gopacket/releases/tag/v$LATEST
|
||||
@ -26,13 +30,9 @@ require (
|
||||
// bump: gomod-golang/text command go get -d golang.org/x/text@v$LATEST && go mod tidy
|
||||
// bump: gomod-golang/text link "Source diff $CURRENT..$LATEST" https://github.com/golang/text/compare/v$CURRENT..v$LATEST
|
||||
golang.org/x/text v0.3.7
|
||||
// bump: gomod-golang-snappy /github.com\/golang\/snappy v(.*)/ https://github.com/golang/snappy.git|^0
|
||||
// bump: gomod-golang-snappy command go get -d github.com/golang/snappy@v$LATEST && go mod tidy
|
||||
// bump: gomod-golang-snappy link "Source diff $CURRENT..$LATEST" https://github.com/golang/snappy/compare/v$CURRENT..v$LATEST
|
||||
github.com/golang/snappy v0.0.4
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/itchyny/timefmt-go v0.1.3 // indirect
|
||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
|
||||
)
|
||||
|
7
go.sum
7
go.sum
@ -11,8 +11,8 @@ github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGg
|
||||
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/wader/gojq v0.12.1-0.20220212115358-b98ce15ac16e h1:gDujpnVkZWYgHVrNbN3FikM2Khp+n/J9NsLEQhl3IFc=
|
||||
github.com/wader/gojq v0.12.1-0.20220212115358-b98ce15ac16e/go.mod h1:tdC5h6dXdwAJs7eJUw4681AzsgfOSBrAV+cZzEbCZs4=
|
||||
github.com/wader/gojq v0.12.1-0.20220302110453-379a885caece h1:sS4y+pGRRXxMPQ7Y1ToBRqc8ImcfK15TCUPNnYYKGJw=
|
||||
github.com/wader/gojq v0.12.1-0.20220302110453-379a885caece/go.mod h1:Pq2wrnwmiGxsaT62vOTEXkH3J3tI81VHJ2K2ZePP6oI=
|
||||
github.com/wader/readline v0.0.0-20220117233529-692d84ca36e2 h1:AK4wt6mSypGEVAzUcCfrJqVD5hju+w81b9J/k0swV/8=
|
||||
github.com/wader/readline v0.0.0-20220117233529-692d84ca36e2/go.mod h1:TJUJCkylZhI0Z07t2Nw6l6Ck7NiZqUpnMlkjEzN7+yM=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
@ -25,8 +25,9 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc=
|
||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
|
@ -31,7 +31,9 @@ def _eval_query_rewrite($opts):
|
||||
_query_transform_pipe_last(_query_ident)
|
||||
end
|
||||
| if $opts.catch_query then
|
||||
_query_try(.; $opts.catch_query)
|
||||
# _query_query to get correct precedence and a valid query
|
||||
# try (1+1) catch vs try 1 + 1 catch
|
||||
_query_try(. | _query_query; $opts.catch_query)
|
||||
end
|
||||
| _query_pipe(
|
||||
$opts.input_query // _query_ident;
|
||||
|
@ -83,11 +83,11 @@ def help: help(null);
|
||||
| . as $e
|
||||
| if length == 1 then
|
||||
( "> \($e[0])"
|
||||
, (null | try _eval($e[0]) | tojson catch "error: \(.)")
|
||||
, (null | try (_eval($e[0]) | tojson) catch "error: \(.)")
|
||||
)
|
||||
else
|
||||
( "> \($e[0] | tojson) | \($e[1])"
|
||||
, ($e[0] | try _eval($e[1]) | tojson catch "error: \(.)")
|
||||
, ($e[0] | try (_eval($e[1]) | tojson) catch "error: \(.)")
|
||||
)
|
||||
end
|
||||
)
|
||||
|
@ -2,6 +2,14 @@
|
||||
def _query_null:
|
||||
{term: {type: "TermTypeNull"}};
|
||||
|
||||
# . -> (.)
|
||||
def _query_query:
|
||||
{ term: {
|
||||
type: "TermTypeQuery",
|
||||
query: .
|
||||
}
|
||||
};
|
||||
|
||||
# string
|
||||
def _query_string($str):
|
||||
{ term: {
|
||||
|
@ -34,7 +34,8 @@ def _complete_keywords:
|
||||
def _complete_scope:
|
||||
[scope[], _complete_keywords[]];
|
||||
def _complete_keys:
|
||||
[keys[]?, _extkeys[]?];
|
||||
# uses try as []? will not catch errors
|
||||
[try keys[] catch empty, try _extkeys[] catch empty];
|
||||
|
||||
# TODO: handle variables via ast walk?
|
||||
# TODO: refactor this
|
||||
|
2
pkg/interp/testdata/value.fqtest
vendored
2
pkg/interp/testdata/value.fqtest
vendored
@ -41,7 +41,7 @@ mp3> .frames[0].header.bitrate | (topath | path_to_expr), tovalue, toactual, tos
|
||||
4
|
||||
56000
|
||||
null
|
||||
mp3> . | (root, buffer_root, format_root, parent | try topath | path_to_expr catch .), [parents | topath | path_to_expr]
|
||||
mp3> . | (root, buffer_root, format_root, parent | try (topath | path_to_expr) catch .), [parents | topath | path_to_expr]
|
||||
"."
|
||||
"."
|
||||
"."
|
||||
|
Loading…
Reference in New Issue
Block a user