diff --git a/doc/demo.sh b/doc/demo.sh index a9044048..e288405b 100755 --- a/doc/demo.sh +++ b/doc/demo.sh @@ -17,6 +17,9 @@ echo c "Show ID3v2 tag inside mp3 file" s "fq '.headers[0]' file.mp3" echo +c "Decode at two offsets as mp3_frame and show bitrate" +s "fq -d raw 'tobytes[0xb79,0xc49:] | mp3_frame.header.bitrate' file.mp3" +echo c "Extract PNG file" s "fq '.headers[].frames[] | select(.id == \"APIC\")?.picture | tobits' file.mp3 >file.png" s "file file.png" @@ -24,5 +27,9 @@ rm -f file.png echo c "Resolution of embedded PNG cover art as YAML" s "fq -r '.headers[0].frames[] | grep_by(.id == \"APIC\") | grep_by(.type == \"IHDR\") | {res: {width, height}} | toyaml' file.mp3" +#echo c "Add query parameter to URL" -s "echo 'http://host?a=b' | fq -Rr 'fromurl | .query.b = 1234 | tourl'" +s "echo 'http://host?a=b' | fq -Rr 'fromurl | .query.b = \"a b c\" | tourl'" +echo +c "Extract JSON and base64 encoded query parameter p" +s "echo 'https://host?p=eyJhIjoiaGVsbG8ifQ%3D%3D' | fq -R 'fromurl.query.p | frombase64 | fromjson'" diff --git a/doc/demo.svg b/doc/demo.svg index ba726ee3..1372101e 100644 --- a/doc/demo.svg +++ b/doc/demo.svg @@ -1,4 +1,4 @@ - + diff --git a/pkg/interp/help.jq b/pkg/interp/help.jq index 65828778..339fe121 100644 --- a/pkg/interp/help.jq +++ b/pkg/interp/help.jq @@ -93,13 +93,16 @@ def _help($arg0; $topic): , " fq . file" , " fq d file" , " fq tovalue file" + , " fq -r totoml file.yml" + , " fq -s -d html 'map(.html.head.title?)' *.html" , " cat file.cbor | fq -d cbor torepr" , " fq 'grep(\"^main$\") | parent' /bin/ls" - , " fq 'grep_by(format == \"exif\") | d' *.png *.jpeg" + , " fq -r 'grep_by(.protocol==\"icmp\").source_ip | tovalue' *.pcap" + , " fq -i" ) elif . == "banner" then ( "fq - jq for binary formats" - , "Tool, language and decoders for inspecting binary data." + , "Tool, language and decoders for working with binary data." , "For more information see https://github.com/wader/fq" ) elif . == "args" then diff --git a/pkg/interp/testdata/args.fqtest b/pkg/interp/testdata/args.fqtest index 0daf3209..39641e99 100644 --- a/pkg/interp/testdata/args.fqtest +++ b/pkg/interp/testdata/args.fqtest @@ -4,7 +4,7 @@ stderr: Usage: fq [OPTIONS] [--] [EXPR] [FILE...] $ fq -h fq - jq for binary formats -Tool, language and decoders for inspecting binary data. +Tool, language and decoders for working with binary data. For more information see https://github.com/wader/fq Usage: fq [OPTIONS] [--] [EXPR] [FILE...] @@ -13,9 +13,12 @@ Example usages: fq . file fq d file fq tovalue file + fq -r totoml file.yml + fq -s -d html 'map(.html.head.title?)' *.html cat file.cbor | fq -d cbor torepr fq 'grep("^main$") | parent' /bin/ls - fq 'grep_by(format == "exif") | d' *.png *.jpeg + fq -r 'grep_by(.protocol=="icmp").source_ip | tovalue' *.pcap + fq -i --arg NAME VALUE Set variable $NAME to string VALUE --argdecode NAME PATH Set variable $NAME to decode of PATH