-
-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature idea: wrap command arguments to multiple lines #690
Comments
In general, I'd say the answer in shfmt for this is #80. If you want stricter rules, like "one argument/flag per line", I think that's too strict/aggressive for a tool as generic as shfmt. But you could certainly write a tool very similar to shfmt which applies extra transformations; the syntax package contains both parsing and printing of programs. |
👍 It wouldn't have to be the default, but maybe something one can enable via configuration settings. Most other languages I work in have code formatters that let you wrap lines automatically in some form or the other. Thank you for writing this tool, it's been very helpful. ☀️ |
@mikez, https://github.com/noperator/sol will do this for you. For example, using $ echo 'ffmpeg -ss 12:34 -i https://example.com/video.mp4 -vframes 1 -q:v 2 path/to/wonderful/screenshot.jpg' | sol -a
ffmpeg \
-ss 12:34 \
-i https://example.com/video.mp4 \
-vframes 1 \
-q:v 2 path/to/wonderful/screenshot.jpg
Agree—I use sol to handle 95% of formatting and then tweak the result as needed. In this case, you may want to manually insert a line break before the final path argument. |
@noperator Thanks for the pointer to your package! 😵💫😎 |
Python
In Python code formatters, long lines like these:
get changed to
Bash
How about, in bash, if sufficiently long lines:
were changed to
There would be some heuristics involved, but even a close approximation would save lots of reformatting. Are there any libraries or scripts around attempting to do this already?
The text was updated successfully, but these errors were encountered: