Purty 0.4.0 released

:tada: :tada: :tada:

Time for another weekly release of purty. You can grab the npm package or go directly for the binaries.

Notes from the changelog

0.4.0

Configuration and customization

This release had only a few additions, but they were big!

The first allows selecting between dynamic and static printing. Dynamic printing is what most people think of when they think of a pretty printer, it’s how prettier and similar tools work. Static printing is more consistent with the output and similar to how gofmt and similar tools work.

The second allows configuring purty with a file instead of command line arguments. That should allow for more reproducability and ease of use in the future. We’re using Dhall as the configuration language because it should make working with the file easier in the long run.

Additions

Changes

Deletions

3 Likes

Great work!

Do you have an example Dhall config file? Also, can I configure the line length in the config file?

For sure: https://gitlab.com/joneshf/purty/snippets/1714537

You can use that in at least a few ways:

  1. Download the file and use it locally. Probably the most straight forward way to do it. Your .purty.dhall file would look like this:

     { formatting =
         < Static = {=} | Dynamic : {} >
     , verbosity =
         < NotVerbose = {=} | Verbose : {} >
     , output =
         < StdOut = {=} | InPlace : {} >
     }
    
  2. Import it in the .purty.dhall file:

     https://gitlab.com/joneshf/purty/snippets/1714537/raw
    

    That can be the entire .purty.dhall file. Dhall will handle importing it and making everything work.

  3. Import it in the .purty.dhall file and verify the contents of the file:

     https://gitlab.com/joneshf/purty/snippets/1714537/raw sha256:c667e904ad11deb56534b3156ead983a59def3533d5766fcdad37fd6a4390f86
    

    The sha256:c667e904ad11deb56534b3156ead983a59def3533d5766fcdad37fd6a4390f86 part forces dhall to verify the integrity of the import. That’s maybe a saner move than the previous suggestion.

  4. Use it as a base to extend the configuration:

         let defaultConfig =
               https://gitlab.com/joneshf/purty/snippets/1714537/raw sha256:c667e904ad11deb56534b3156ead983a59def3533d5766fcdad37fd6a4390f86 
    
     in  defaultConfig ⫽ { verbosity = < Verbose = {=} | NotVerbose : {} > }
    

    The // operator combines records. It prefers fields from the right record over the left record.

Let me know if that all makes sense.

I’ll try to make config easier in the future.

Not yet, but I’ll add it.