fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
773 stars 194 forks source link

Fix 2854, accidental treatment of old flags as folders #3024

Closed dawedawe closed 9 months ago

dawedawe commented 9 months ago

fixes #2854

It's a bit complicated, but first we treated unknown flags as input folders these input folders weren't found and then we treated these folders as output folders these output folders didn't exist, so we created them, hence the famous --recurse folder came into life.

MangelMaxime commented 9 months ago

Hello,

For me, the problem reported in #2854 is not limited to flags.

For example, if I run dotnet fantomas dir1 dir2 where dir1 and dir2 doesn't exist.

Then fantomas creates these folders.

these input folders weren't found and then we treated these folders as output folders

This behaviour feels strange to me, this means if the user makes a typo then the command has a different behaviour than what he would expect.

If this is for legacy reason, that's unfortunate.

Otherwise, I think it would be nice to treat input folders as input only.

For example, if I run cd dir1 when dir1 doesn't exist, cd doesn't try to create that folder. It report that the folder doesn't exist so I can fix my command invocation.

dawedawe commented 9 months ago

I pushed a change that should handle old flags and non-existing folders as @MangelMaxime described.

dawedawe commented 9 months ago

@MangelMaxime Please test our latest alpha It should handle your issues more gracefully.

MangelMaxime commented 9 months ago

I confirm that the alpha doesn't create the folder if it doesn't exist:

➜  Glutinum.Converter git:(main) ✗ dotnet fantomas di1 dir2 
Input path 'di1' not found.
➜  Glutinum.Converter git:(main) ✗ dotnet fantomas src dir2
Input path 'dir2' not found.
# src folder exist

Thank you