ocaml/dune

dune fmt should be able to format single files

开放

#7,287 创建于 2023年3月11日

 (7 条评论) (2 个反应) (1 位负责人)OCaml (478 个派生)github user discovery
good first issue

仓库指标

星标
 (1,882 个星标)
PR 合并指标
 (平均合并 1天 20小时) (30 天内合并 345 个 PR)

描述

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.

贡献者指南