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

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

Merged
merged 4 commits into from
Dec 22, 2023

Conversation

dawedawe
Copy link
Member

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.

results.TryGetResult <@ Arguments.Input @>
|> Option.map (fun input ->
input
|> List.filter (fun s -> not (s.StartsWith("--", StringComparison.Ordinal)))) // don't accidentally treat old flags as folders
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there not any Argu configuration we are missing here? Don't parse invalid input or something?

@MangelMaxime
Copy link

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
Copy link
Member Author

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

Copy link
Contributor

@nojaf nojaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dawedawe dawedawe merged commit c43224d into fsprojects:main Dec 22, 2023
5 checks passed
@dawedawe dawedawe deleted the fix-2854 branch December 22, 2023 09:29
@dawedawe
Copy link
Member Author

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

@MangelMaxime
Copy link

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

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

Successfully merging this pull request may close these issues.

"fantomas --recurse" creates a "--recurse" directory
3 participants