anoma / juvix

A language for intent-centric and declarative decentralised applications
https://docs.juvix.org
GNU General Public License v3.0
457 stars 53 forks source link

Juvix format does not work as expected #3000

Open heueristik opened 2 months ago

heueristik commented 2 months ago

Steps to reproduce:

checkout this commit: https://github.com/anoma/juvix-anoma-test/commit/41b428ea7fca3e0414da8ea74af5817f0550d715

  1. juvix clean --global && juvix clean && juvix dependencies update
  2. Execute juvix format --check and observe that it does nothing
  3. Exectue juvix-format --in-place and observe that it change 2 out of 4 files (it didn't change the files in the tests folder, which is unexpected)

Moreover, it would be nice if, both, juvix format --check and juvix format --in-place would return a list containing the files that are malformatted or were formatted in-place, respectively.

janmasrovira commented 2 months ago

it does not report about the files inside the tests folder because that's a different package (i.e. there is a package.juvix inside).

I've tried juvix format --check and it returns an error exit code but no output. That's the intended behaviour.

From juvix format --help:

Given a file, it prints the reformatted source to standard output.
Given a project directory it prints a list of unformatted files in the project.
Given no argument it prints a list of unformatted files in the project which contains the current directory.
[..]
  --check                  Do not print reformatted sources or unformatted file
                           paths to standard output.

So, if you want to get the list of unformatted files, you shouldn't pass --check.

It would be nice if [..] juvix format --in-place would return a list containing the files that are [..] formatted in-place

I agree.

We could consider rethinking the cli interface to make it more intuitive. One option would be to rename --check to --silent (or something similar). Or even remove the flag.