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 configure options for ghc-options layout. #66

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

philderbeast
Copy link

@philderbeast philderbeast commented Jan 10, 2023

Picking up #37 as a fix for #34, I've removed the sorting and added options to control this, leaving the default as-is.

$ cabal run cabal-fmt -- --help
Build profile: -w ghc-9.4.4 -O1
...

Usage: cabal-fmt [--Werror | --Wno-error | --indent N | --tabular | 
                   --no-tabular | --ghc-options-flow | --ghc-options-vert | 
                   --cabal-file | (-n|--no-cabal-file) | --stdout | 
                   (-i|--inplace) | (-c|--check)] [FILE...] [--version]

  Reformat .cabal files

Available options:
  --Werror                 Treat warnings as errors
  --indent N               Indentation
  --tabular                Tabular formatting
  --ghc-options-flow       ghc-options: flow options (default)
  --ghc-options-vert       ghc-options: one option per line
  -n,--no-cabal-file       Don't parse as .cabal file
  --stdout                 Write output to stdout (default)
  -i,--inplace             Process files in-place
  -c,--check               Fail with non-zero exit code if input is not
                           formatted
  FILE...                  input files
  -h,--help                Show this help text
  --version                Show version

The two new fixture files were generated by cabal init to which I added some ghc-options and removed some of the top-level fields, not needed for testing, like author and maintainer.

I see that cabal init generates a .cabal file with 4 spaces indentation whereas the default for cabal-fmt is 2 spaces.

-Werror=unused-imports
-eventlog
-O0
+RTS -A32M -RTS
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you know of a way to keep +RTS -A32M -RTS as one line while options prefixed with -W as one per line then that could be very nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants