Won't format files that don't end in `.nu`
Describe the bug
I have a shell command written in nu that has a shebang at the top. I cannot get nufmt to format this file unless I rename it to *.nu or I use the --stdin flag.
https://github.com/nushell/nufmt/blob/35962223fbd4c1a924b4ccfb8c7ad81fe2863b86/src/main.rs#L319-L322
Steps To Reproduce
Steps to reproduce the behavior:
- Have nu file without the
.nufile extension such asmy-command - Run
nufmt my-command - Observe error "warning: no Nushell files found under the given path(s)⏎"
Expected behavior
I expect nufmt to format the file because I specified the file on the CLI.
Environment
Please run rustc --version and paste the result.
[user@system:~]$ rustc --version
rustc 1.91.1 (ed61e7d7e 2025-11-07)
I'm not surprised. nufmt isn't even beta yet and I wouldn't suggest using it. However, we are able to take PRs to help fix problem. I myself use topiary-nushell right now.
I'm not surprised. nufmt isn't even beta yet and I wouldn't suggest using it. However, we are able to take PRs to help fix problem. I myself use topiary-nushell right now.
Thanks. That looks like a really interesting project.
- https://github.com/blindFS/topiary-nushell
- https://github.com/tweag/topiary
Hey! For completeness, if you format a directory with nufmt, should nufmt check if the shebang of everyfile to see if it needs formatting or not? This would significantly hit performance if you need to read thousands of files just to format a couple of them
Hey! For completeness, if you format a directory with nufmt, should nufmt check if the shebang of everyfile to see if it needs formatting or not? This would significantly hit performance if you need to read thousands of files just to format a couple of them
The feature could be designed to be disabled with a flag if there is a performance hit for edge cases.
Maybe a link to topiary-nushell could be included in the readme warning?