Closed witoldsz closed 1 year ago
Hello,
Upgrading from version 4.7.9 to 6.0.1 entails two major version bumps, which may introduce breaking changes. Please be aware of this when making the update.
It's worth noting that if you pass a non-existent folder when multiple folders are being passed, the folder will be created as expected.
Mixing versions in your setup seems rather specific on how you choose to do things. You can detect the current version using dotnet fantomas --version
and adjust your build script accordingly.
OK, so I was fooled by official documentation at https://fsprojects.github.io/fantomas/docs/end-users/GettingStarted.html
USAGE: dotnet fantomas [--help] [--recurse] [--force] [--profile] [--fsi
] [--stdin] [--stdout] [--out ] [--check] [--daemon] [--version] [ ]
showing the --recurse
is a valid flag. I can see the tool does not show it anymore.
On the other side, I must admit this is very strange to identify the --recurse
configuration flag as a directory name (even if it is not a valid flag) and also it is very strange to default to create any non-existing file or directory as a new directory.
Thanks for looking into my case!
P.S. It was tricky to remove that directory:
witoldsz@678db1ca1a61:/app/modules/event-logger2$ rmdir --recurse
rmdir: unrecognized option '--recurse'
Try 'rmdir --help' for more information.
witoldsz@678db1ca1a61:/app/modules/event-logger2$ rmdir -- --recurse
It is expected to treat any --something
as a flag. Maybe fantomas
could follow the rule?
GettingStarted.html
was out of date indeed, I raised https://github.com/fsprojects/fantomas/pull/2857
For whomever it may be useful, my Makefile
script works this around like this:
# TODO: upgrade fantomas everywhere and remove this workaround
FANTOMAS = dotnet fantomas `dotnet fantomas --version |grep -q v4.7 && echo --recurse`
check-format: tool-restore
$(FANTOMAS) --check .
format: tool-restore
$(FANTOMAS) .
[...]
Hello, I often makes mistakes when invoking fantomas and because of that it creates empty directories.
It's worth noting that if you pass a non-existent folder when multiple folders are being passed, the folder will be created as expected.
Why is the expected behaviour to create an empty directory?
If I provide a single non existing directory then it reports it as missing which helps diagnostic the problem.
To me it feels strange to me that a formatting tool create additional files and not just consume only existing files.
You could format a directory and output it into a different directory. If that destination directory does not exist we create it. Because the source and destination are the same that happens.
Sorry, I don't understand do you have a command example?
Looking at the help message:
USAGE: dotnet fantomas [--help] [--force] [--profile] [--out <string>] [--check] [--daemon] [--version] [--verbosity <string>] [<string>...]
INPUT:
<string>... Input paths: can be multiple folders or files with *.fs,*.fsi,*.fsx,*.ml,*.mli extension.
OPTIONS:
--force Print the output even if it is not valid F# code. For debugging purposes only.
--profile Print performance profiling information.
--out <string> Give a valid path for files/folders. Files should have .fs, .fsx, .fsi, .ml or .mli extension only. Multiple files/folders are not supported.
--check Don't format files, just check if they have changed. Exits with 0 if it's formatted correctly, with 1 if some files need formatting and 99 if there was an
internal error
--daemon Daemon mode, launches an LSP-like server to can be used by editor tooling.
--version Displays the version of Fantomas
--verbosity, -v <string>
Set the verbosity level. Allowed values are n[ormal] and d[etailed].
--help display this list of options.
It seems that if I do dotnet fantomas dir1 dir2
then both dir1 dir2
refers to <string>...
which is the input paths
arguments.
I also tried to use the --out
option as I was thinking this is what you are referring to when speaking of a different directory but I was not able to make it works.
dotnet fantomas src --out fantomas
fails with
➜ Glutinum.Converter git:(main) ✗ dotnet fantomas --out fantomas src
Formatted │ 0 │ Ignored │ 0 │ Unchanged │ 0 │ Errored │ 30
Failed to format file: src/Glutinum.Converter/Utils/Keywords.fs
Failed to format file: src/Glutinum.Converter/Utils/Naming.fs
Failed to format file: src/Glutinum.Converter/Utils/String.fs
Failed to format file: src/Glutinum.Converter/Reader/TypeParameters.fs
Failed to format file: src/Glutinum.Converter/Reader/ClassDeclaration.fs
Failed to format file: src/Glutinum.Converter/Reader/Types.fs
Failed to format file: src/Glutinum.Converter/Reader/ModuleDeclaration.fs
Failed to format file: src/Glutinum.Converter/Reader/TypeNode.fs
Failed to format file: src/Glutinum.Converter/Reader/FunctionDeclaration.fs
...
Even if dotnet fantomas src
works.
I really don't quite remember how it works. This seems to somewhat works for me: dotnet fantomas .\Style\ --out Foobar
. Folder Foobar
was created and contains the formatted files.
However there is something weird with the output file name.
I really don't quite remember how it works. This seems to somewhat works for me:
dotnet fantomas .\Style\ --out Foobar
. FolderFoobar
was created and contains the formatted files. However there is something weird with the output file name.
Ok perhaps, there is something strange in my project
Just updated from
fantomas-tool 4.7.9
tofantomas 6.0.1
and it creates--recurse
directories in my modules.Steps to reproduce:
As you can see, the
--recurse
directory appeared.I can see, the
fantomas 6.x
does not require--recurse
anymore, but my project upgrading to fantomas 6 is in progress and the--recurse
flag is still required by other modules (using older fantomas version) and there is one build script for them all.