twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.9k stars 478 forks source link

Allow to use `.chezmoi.stdin` in `execute-template` command #2769

Closed felipecrs closed 1 year ago

felipecrs commented 1 year ago

Is your feature request related to a problem? Please describe.

I was reporting https://github.com/twpayne/chezmoi/issues/2768, and my first attempt to build a command to reproduce the issue was:

printf "%s\n" "[boot]" "systemd=true" | chezmoi execute-template '{{ .chezmoi.stdin | fromIni | toIni}}'

And, I understand that stdin should actually be used to supply in the template itself.

Describe the solution you'd like

I think it could work:

Describe alternatives you've considered

N/A

Additional context

This is just a suggestion, and I'm not sure if it's even a good idea, or if it's even worth implementing. Anyway, if you dislike feel free to close this issue, no hard feelings!

halostatue commented 1 year ago

I think that this is a good idea as it will make it easier to test modify templates. Maybe with a flag of --modify-template or --use-stdin specifically against execute-template commands.

The usual trick of adding {{/* chezmoi:modify-template */}} does not work with execute-template and is, I think, opaque for this purpose.