jk icon indicating copy to clipboard operation
jk copied to clipboard

More control over in/out formats

Open squaremo opened this issue 5 years ago • 0 comments

  • [x] forcing the output format for jk generate

This adds a flag jk generate --format, which will force the output to either YAML or JSON.

If printing to stdout, this means all values are printed as whichever foramt, with streams being inlined as before.

If writing to files, the file extension when present will be changed. Values with a stream (or multidoc) format -- YAMLStream, JSONStream -- will still be written as streams.

  • [x] force the output format for transform
  • [x] give a format for input from stdin

Using an argument of - now instructs jk transform to read values from stdin (as well as any files supplied as arguments).

The new flag --stdin-format tells it what format to expect (it defaults to 'yaml'). The possible values are json meaning expect JSON values, and yaml meaning expect a YAML stream.

some-process | jk transform --stdin-format=json  -m transform/module -

Reading from stdin implies --stdout as well, since the alternative is to make up a filename to write it to. I'm not sure of the ergonomics of that choice.

squaremo avatar May 26 '20 08:05 squaremo