Skip to content
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

Enforce/respect a maximum line length when using "just --fmt" command to reformat a justfile #2387

Open
JohnstonJ opened this issue Sep 22, 2024 · 1 comment

Comments

@JohnstonJ
Copy link

The just --fmt command will take nicely formatted code with a reasonable maximum line length, and turn it into a very long unreadable line.

For example, if I try to format this using just --fmt:

SETUP_DEBUG_ENV := if os_family() == "windows" {
    "$env:PKG_CONFIG = \"" + justfile_directory() +
        "\\vcpkg_installed\\x64-windows-release\\tools\\pkgconf\\pkgconf.exe\"\n" +
    "$env:PKG_CONFIG_PATH = \"" + justfile_directory() +
        "\\vcpkg_installed\\x64-windows-static\\debug\\lib\\pkgconfig\"\n"
} else {
    "exit 1"
}

it will get reformatted to this mess:

SETUP_DEBUG_ENV := if os_family() == "windows" { "$env:PKG_CONFIG = \"" + justfile_directory() + "\\vcpkg_installed\\x64-windows-release\\tools\\pkgconf\\pkgconf.exe\"\n" + "$env:PKG_CONFIG_PATH = \"" + justfile_directory() + "\\vcpkg_installed\\x64-windows-static\\debug\\lib\\pkgconfig\"\n" } else { "exit 1" }

Many other reformatting tools (black, rustfmt, etc) provide a configurable option for maximum line length. Maybe just needs something similar, and then it could make better decisions about whether to place statements like the above one onto one line or multiple lines.

@casey
Copy link
Owner

casey commented Sep 22, 2024

I definitely agree that the current situation is not great. --fmt is pretty bad, which is why it's still --unstable. I have a feeling that making it better would be pretty complicated, and require a lot of concerted effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants