diff --git a/_gojq b/_gojq index 01e4c4f7..2dc00336 100644 --- a/_gojq +++ b/_gojq @@ -7,7 +7,7 @@ _gojq() '(-r --raw-output -j --join-output)--raw-output0[implies -r with NUL character delimiter]' \ '(-r --raw-output --raw-output0 -j --join-output)'{-j,--join-output}'[implies -r with no newline delimiter]' \ '(-c --compact-output --indent --tab --yaml-output)'{-c,--compact-output}'[output without pretty-printing]' \ - '(-c --compact-output --tab --yaml-output)--indent=[number of spaces for indentation]:indentation count:(2 4 8)' \ + '(-c --compact-output --tab --yaml-output)--indent[number of spaces for indentation]:indentation count:(2 4 8)' \ '(-c --compact-output --indent --yaml-output)--tab[use tabs for indentation]' \ '(-c --compact-output --indent --tab )--yaml-output[output in YAML format]' \ '(-C --color-output -M --monochrome-output)'{-C,--color-output}'[output with colors even if piped]' \ @@ -18,7 +18,7 @@ _gojq() '(-R --raw-input --stream )--yaml-input[read input as YAML format]' \ '(-s --slurp)'{-s,--slurp}'[read all inputs into an array]' \ '(-f --from-file 1)'{-f,--from-file}'[load query from file]:filename of jq query:_files' \ - '*-L=[directory to search modules from]:module directory:_directories' \ + '*'{-L,--library-path}'[directory to search modules from]:module directory:_directories' \ '*--arg[set a string value to a variable]:variable name: :string value' \ '*--argjson[set a JSON value to a variable]:variable name: :JSON value' \ '*--slurpfile[set the JSON contents of a file to a variable]:variable name: :JSON file:_files' \ diff --git a/cli/cli.go b/cli/cli.go index 80e9c06b..ac7f582d 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -58,7 +58,7 @@ type flagopts struct { OutputRaw0 bool `long:"raw-output0" description:"implies -r with NUL character delimiter"` OutputJoin bool `short:"j" long:"join-output" description:"implies -r with no newline delimiter"` OutputCompact bool `short:"c" long:"compact-output" description:"output without pretty-printing"` - OutputIndent *int `long:"indent" description:"number of spaces for indentation"` + OutputIndent *int `long:"indent" args:"number" description:"number of spaces for indentation"` OutputTab bool `long:"tab" description:"use tabs for indentation"` OutputYAML bool `long:"yaml-output" description:"output in YAML format"` OutputColor bool `short:"C" long:"color-output" description:"output with colors even if piped"` @@ -69,11 +69,11 @@ type flagopts struct { InputYAML bool `long:"yaml-input" description:"read input as YAML format"` InputSlurp bool `short:"s" long:"slurp" description:"read all inputs into an array"` FromFile bool `short:"f" long:"from-file" description:"load query from file"` - ModulePaths []string `short:"L" description:"directory to search modules from"` - Arg map[string]string `long:"arg" description:"set a string value to a variable"` - ArgJSON map[string]string `long:"argjson" description:"set a JSON value to a variable"` - SlurpFile map[string]string `long:"slurpfile" description:"set the JSON contents of a file to a variable"` - RawFile map[string]string `long:"rawfile" description:"set the contents of a file to a variable"` + ModulePaths []string `short:"L" long:"library-path" args:"dir" description:"directory to search modules from"` + Arg map[string]string `long:"arg" args:"name value" description:"set a string value to a variable"` + ArgJSON map[string]string `long:"argjson" args:"name value" description:"set a JSON value to a variable"` + SlurpFile map[string]string `long:"slurpfile" args:"name file" description:"set the JSON contents of a file to a variable"` + RawFile map[string]string `long:"rawfile" args:"name file" description:"set the contents of a file to a variable"` Args []any `long:"args" positional:"" description:"consume remaining arguments as positional string values"` JSONArgs []any `long:"jsonargs" positional:"" description:"consume remaining arguments as positional JSON values"` ExitStatus bool `short:"e" long:"exit-status" description:"exit 1 when the last value is false or null"` diff --git a/cli/flags.go b/cli/flags.go index 17441b5b..1383c8b8 100644 --- a/cli/flags.go +++ b/cli/flags.go @@ -186,22 +186,10 @@ func formatFlags(opts any) string { } sb.WriteString("--") sb.WriteString(flag) - switch val.Field(i).Kind() { - case reflect.Bool: - sb.WriteString(" ") - case reflect.Map: - if strings.HasSuffix(flag, "file") { - sb.WriteString(" name file") - } else { - sb.WriteString(" name value") - } - default: - if _, ok = tag.Lookup("positional"); !ok { - sb.WriteString("=") - } - } - } else { - sb.WriteString("=") + } + if args, ok := tag.Lookup("args"); ok { + sb.WriteString(" ") + sb.WriteString(args) } sb.WriteString(strings.Repeat(" ", 24-(sb.Len()-m))) sb.WriteString(tag.Get("description")) diff --git a/cli/test.yaml b/cli/test.yaml index efbba4b2..e05fdc61 100644 --- a/cli/test.yaml +++ b/cli/test.yaml @@ -7902,7 +7902,7 @@ - name: module directory option args: - -c - - -L + - --library-path - 'testdata' - 'import "7" as $foo; $foo, $foo::foo' input: '0' @@ -7913,7 +7913,7 @@ - name: module directory option args: - -c - - -L + - --library-path - 'testdata' - 'import "m1" as $x; $x, $x::x, $x[1].m1*100000000000000000000' input: '0'