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

Add -R, --recursive option for implying --mode inplace and all *.hs file under given directory #1086

Closed
evan0greenup opened this issue Jan 1, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@evan0greenup
Copy link

Is your feature request related to a problem? Please describe.

For modern Haskell usage, reformatting a whole haskell project is certainly more often then single file. according to the README.md, ormolu --mode inplace $(find . -name '*.hs') or ormolu --mode inplace $(git ls-files '*.hs') is too long and inconvenient for user to input.

Describe the solution you'd like
A -R or --recursive option would works. It implies --mode inplace and the path on the end will be the directory to make recursive reformatting.

Unlike ormolu --mode inplace $(find . -name '*.hs'), -R can identify scm repository. If the path is located inside Git workspace or Mercurial workspace. It can automatically ignore the files which is ignored by .gitignore spec.

Describe alternatives you've considered
It would be good to referencing black for python https://github.com/psf/black

Additional context
The final functionality should like this

$ cd haskell-sample-project/
$ ormolu -R .
totally 150 *.hs files found, 23 *.hs file reformated!!!
@amesgen
Copy link
Member

amesgen commented Jan 1, 2024

See #691, #697, #910 for prior discussions on this topic, and #1054 for a related discussion.

@mrkkrp
Copy link
Member

mrkkrp commented Jan 19, 2024

Closing as a duplicate of #691. I'm not sure how exactly ormolu --mode inplace $(git ls-files '*.hs') is too long or inconvenient. It is already a one-liner, and it can be further shortened if you create a bash alias. Personally, I made this little function in Nushell:

# Format all Haskell files in the current git repository.
def "ormolu all" [] {
    ormolu -i (git ls-files '*.hs' '*.hs-boot' | lines)
}

I do see that there has been multiple requests like this, but the correct implementation here would need to

  • call git ls-files at least in some cases, since you seem to accept that excluding gitignored files is a desirable feature; or
  • re-implement the logic of git ls-files.

Otherwise there is a host of extra settings we would need to think about, such as what to do with symbolic links when we traverse a directory tree.

I prefer to avoid dealing with this complexity in an already pretty complex project.

@mrkkrp mrkkrp closed this as completed Jan 19, 2024
@mrkkrp mrkkrp added the duplicate This issue or pull request already exists label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants