From 7bc25219383922cb4784f68307ae612bfc328b17 Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Sat, 29 Jan 2022 12:18:03 +0100 Subject: [PATCH] doc,interp: Add some example usages to cli help --- doc/usage.md | 12 ++++++++++-- pkg/interp/interp.jq | 8 ++++++++ pkg/interp/testdata/args.fqtest | 8 ++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/doc/usage.md b/doc/usage.md index 5c9c7be6..5af3b330 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -298,6 +298,14 @@ For more information see https://github.com/wader/fq Usage: fq [OPTIONS] [--] [EXPR] [FILE...] +Example usages: + fq . file + fq d file + fq tovalue file + cat file.cbor | fq -d cbor torepr + fq 'grep("^main$") | parent' /bin/ls + fq 'grep_by(format == "exif") | d' *.png *.jpeg + --arg NAME VALUE Set variable $NAME to string VALUE --argjson NAME JSON Set variable $NAME to JSON --color-output,-C Force color output @@ -310,9 +318,9 @@ Usage: fq [OPTIONS] [--] [EXPR] [FILE...] --include-path,-L PATH Include search path --join-output,-j No newline between outputs --monochrome-output,-M Force monochrome output ---null-input,-n Null input (use input and inputs to read input) +--null-input,-n Null input (use input and inputs functions to read input) --null-output,-0 Null byte between outputs ---option,-o KEY=VALUE Set option, eg: color=true (use options to see all options) +--option,-o KEY=VALUE Set option, eg: color=true (use options function to see all options) --raw-file NAME PATH Set variable $NAME to string content of file --raw-input,-R Read raw input strings (don't decode) --raw-output,-r Raw string output (without quotes) diff --git a/pkg/interp/interp.jq b/pkg/interp/interp.jq index bb352a54..a13f7603 100644 --- a/pkg/interp/interp.jq +++ b/pkg/interp/interp.jq @@ -300,6 +300,14 @@ def _main: , "" , _usage($arg0) , "" + , "Example usages:" + , " fq . file" + , " fq d file" + , " fq tovalue file" + , " cat file.cbor | fq -d cbor torepr" + , " fq 'grep(\"^main$\") | parent' /bin/ls" + , " fq 'grep_by(format == \"exif\") | d' *.png *.jpeg" + , "" , args_help_text(_opt_cli_opts) ) | println elif $opts.show_version then diff --git a/pkg/interp/testdata/args.fqtest b/pkg/interp/testdata/args.fqtest index c6071fa8..f93fce01 100644 --- a/pkg/interp/testdata/args.fqtest +++ b/pkg/interp/testdata/args.fqtest @@ -9,6 +9,14 @@ For more information see https://github.com/wader/fq Usage: fq [OPTIONS] [--] [EXPR] [FILE...] +Example usages: + fq . file + fq d file + fq tovalue file + cat file.cbor | fq -d cbor torepr + fq 'grep("^main$") | parent' /bin/ls + fq 'grep_by(format == "exif") | d' *.png *.jpeg + --arg NAME VALUE Set variable $NAME to string VALUE --argjson NAME JSON Set variable $NAME to JSON --color-output,-C Force color output