awslabs/aws-cfn-template-flip

In-place editing

aidansteele opened this issue · 2 comments

I love the idea of cfn-flip, I'd like to integrate it into my workflow. Would you be open to a PR that adds support for in-place editing? Like sed's -i flag, it would overwrite the input file with the output, instead of writing to stdout.

Right now if you run cfn-flip -n -c input.yml input.yml, it just replaces the contents of the file with:

null
...

I'm thining maybe something like -e and --edit, or -r --rewrite.

ctd commented

Hi Aidan,

Thanks for reporting this issue, and apologies it's taken a few days for a response.

I'd call the current behaviour a bug -- we should either be preventing you from specifying the same input and output file, or support the in-line editing behaviour you've described; though an extra command line argument shouldn't be necessary, the correct behaviour should be the default.

As I don't see any reason we should prevent users from writing the flipped output to the same file as the input, I'll look at implementing the latter.

Champion! Amazing turnaround time. Thank you so much!