-
Notifications
You must be signed in to change notification settings - Fork 22
Logic-based pairing for CLI arguments in lists #151
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
When formatting a list vertically, it would be beneficial for nufmt to detect strings starting with -- or - and attempt to keep the immediately following element on the same line. This preserves the "Flag + Value" relationship common in Nushell scripts that build command arguments.
Heuristic:
- Auto-Pairing: If a flag and its subsequent value are on the same line in the source, the formatter should attempt to keep them on the same line even if the list is expanded vertically.
- Respectful Separation: If a flag and its subsequent value are already separated by a newline in the source, the formatter should preserve that separation rather than attempting to "squash" them together.
- Absolute line_length Override: If a flag and its value are on the same line but their combined width exceeds the configured line_length, the formatter must wrap the value onto a new line to maintain the margin.
Minimal reproducer
let base_args: list<string> = [
"--no-pager"
"--output" "json"
"--identifier" "inceptool"
"--lines" ($lines | into string)
"--priority" ($max_pri | into string)
]Output:
let base_args: list<string> = [
"--no-pager"
"--output"
"json"
"--identifier"
"inceptool"
"--lines"
($lines | into string)
"--priority"
($max_pri | into string)
]Excepted:
let base_args: list<string> = [
"--no-pager"
"--output" "json"
"--identifier" "inceptool"
"--lines" ($lines | into string)
"--priority" ($max_pri | into string)
]Environment
- nushell 0.111.0
- nufmt f2f4020
- rustc 1.93.0 (254b59607 2026-01-19) (built from a source tarball)
{
indent: 2
line_length: 80
margin: 1
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request