cdepillabout / pretty-simple

pretty-printer for Haskell data types that have a Show instance
https://hackage.haskell.org/package/pretty-simple
BSD 3-Clause "New" or "Revised" License
243 stars 29 forks source link

Set output options from CLI #34

Open andrew-lei opened 6 years ago

andrew-lei commented 6 years ago

I use a light background for my terminal, so using pStringLightBg would be more useful in my case. I was thinking an executable flag, but maybe a better option would be a compiler flag? Of course no reason not to have both.

cdepillabout commented 6 years ago

This is a great idea.

If you (or anyone else) wanted to send a PR adding a command-line flag, please go ahead.

Using a library like optparse-applicative would be a good idea, since it is relatively well-known.

andrew-lei commented 6 years ago

Sounds good. What to use for the compiler flag? The CPP language extension?

andrew-lei commented 6 years ago

Or perhaps a config file instead? Could use that to e.g. set indentation as well.

cdepillabout commented 6 years ago

Ideally, options for the CLI pretty-simple could be provided the following ways:

I guess we could also be able to set defaults with compiler flags, but that is somewhat unusual for Haskell programs, especially when the ability to set the options in a config file, etc is available.

However, I don't know if there are many people using the CLI pretty-simple other than you and me. So for now I think it is probably good enough to be able to specify the options on the command line. If you want to make sure that light colors are always used, you could create an alias in your ~/.bashrc file:

alias pretty-simple='pretty-simple --color light-bg'

However, if you also wanted to be able to specify options in a config files or environment variables, then please feel free to send PRs for that!

georgefst commented 4 years ago

Note that pretty-simple has become a lot more configurable than when this issue was posted. Ideally, we want to be able to completely specify an OutputOptions from the CLI.