ocaml/dune

dune fmt should be able to format single files

Offen

#7.287 geöffnet am 11.03.2023

 (7 Kommentare) (2 Reaktionen) (1 zugewiesene Person)OCaml (478 Forks)github user discovery
good first issue

Repository-Metriken

Stars
 (1.882 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 1T 20h) (345 gemergte PRs in 30 T)

Beschreibung

We should expand the capabilities of dune fmt so that it can format files passed on the command line. This would probably involve making a more serious implementation for it rather than just being a command line alias for dune build @fmt --auto-promote.

We have two cases for dune fmt file1.

  • If a file can be formatted, then we should format it according to whatever rule @fmt uses.
  • If it cannot be formatted then either we error or do nothing.

Perhaps we can control the behaviour of the second with an option which will allow users to hook up commit scripts like those proposed in https://github.com/ocaml/dune/issues/5107.

It would also pave the way for requesting a file to be formatted, which we can use to implement more sophisticated features like having the latest files changed in version control only be formatted. Again suggested in https://github.com/ocaml/dune/issues/5107.

I will need to do some more thinking about the implementation so making this ticket in the mean time.

Contributor Guide