Better support for .editorconfig in shfmt #720
Replies: 2 comments 1 reply
|
Linking the formatter documentation here for reference. I understand the use case, but I am not comfortable expanding the formatter interface or recommending this pattern as part of Bashly's generation workflow. My reasoning is:
For projects that already use EditorConfig and only need one shared rule for all generated scripts, the workaround shown here remains compatible with the existing contract: formatter: shfmt --filename bin/dummyIn that form, I would therefore prefer to keep Bashly's formatter as a simple stream transformation. More elaborate, file-aware post-processing belongs in the surrounding project workflow; Bashly's settings should not grow into a build-system or pipeline configuration. |
|
and as a side note - if you don't already have your favorite task runner, check out opcode. I am using it in many of my projects, to define tasks like this: # op.conf
build:
op generate
op man
man: bashly render :mandoc doc
generate: bashly generate "$@"
check:
op shellcheck
op shfmt
op test
green ALL CHECKS PASS |
Uh oh!
There was an error while loading. Please reload this page.
Hi. I had some troubles to setup the formatter and ended up learn inconvenience of shfmt used via stdin.
It's easy for a single script, however I believe it would be great to document it
Here is how to apply .editorconfig for multi files. The dummy filename can be used, since the
[bin/*]glob will match it. That allows format several scripts defined in bashly.yml e.g. bin/mycli, bin/mycli2, bin/mytool, bin/myscript. Maybe is it worth to support a file name variableformatter: "shfmt --filename %{target_script}"?Unfortunately I don't see an option to have separate rules per generated script, however I believe it's an unlikely case to happened.
Thanks for creating the bashly, cheers.
All reactions