Enforce/respect a maximum line length when using "just --fmt" command to reformat a justfile
- Dominant language
- Rust
- Stars
- 35.8k
- Forks
- 846
- Avg merge
- 27m
- Merged PRs (30d)
- 3
Description
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.
Contributor guide
Research direction
Start at the `just --fmt` command and reproduce the issue with the provided justfile example. Determine how formatting decisions handle long expressions, then make the maximum line length configurable and verify that formatting respects it without collapsing the example into one unreadable line.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100