kislyuk / yq

Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
https://kislyuk.github.io/yq/
Apache License 2.0
2.57k stars 82 forks source link

tomlq: -i/--in-place can only be used with -y/-Y #130

Closed dcompoze closed 1 year ago

dcompoze commented 3 years ago

Version: tomlq 2.12.2

The --help documentation says that it's possible to update in place using the -i flag:

  -h, --help         show this help message and exit
  --toml-output, -t  Transcode jq JSON output back into TOML and emit it
  --in-place, -i     Edit files in place (no backup - use caution)

But when invoked I get an error:

tomlq: -i/--in-place can only be used with -y/-Y

Which seems to suggest that only yaml files can be updated in-place.

I ended up using the sponge utility from the moreutils package: tomlq --toml-output '<query>' Foo.toml | sponge Foo.toml. But since tomlq already knows how to return toml output it would seem rather straight-forward to make the -i flag work the same way it works with yq.

kislyuk commented 3 years ago

Correct, sponge is the right utility to use in this case. jq does not support -i, so -i is only available when we are capturing and converting jq's output.

kislyuk commented 3 years ago

Sorry, I misread that. What you're pointing out is a bug. tomlq -t should support -i.