haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 697 forks source link

Adding loading indicators to the build command #8943

Open Kleidukos opened 1 year ago

Kleidukos commented 1 year ago

I have been asked for some time now if cabal build could display loading indicators like other project managers do.

The ideal would be to have such a result:

❯ cabal build Cabal
Build profile: -w ghc-9.4.4 -O1
In order, the following will be built (use -v for more details):
 - Cabal-syntax-3.11.0.0 (lib) (first run)
 - Cabal-3.11.0.0 (lib) (first run)
Configuring library for Cabal-syntax-3.11.0.0..
Preprocessing library for Cabal-syntax-3.11.0.0..
Building library for Cabal-syntax-3.11.0.0..
[  1 of 137] Compiling Distribution.Compat.Binary ( src/Distribution/Compat/Binary.hs, /home/hecate/Contrib/cabal/dist-newstyle/build/x86_64-linux/ghc-9.4.4/Cabal-syntax-3.11.0.0/build/Distribution/Compat/Binary.o, /home/hecate/Contrib/cabal/dist-newstyle/build/x86_64-linux/ghc-9.4.4/Cabal-syntax-3.11.0.0/build/Distribution/Compat/Binary.dyn_o )
[  2 of 137] Compiling Distribution.Compat.Exception ( src/Distribution/Compat/Exception.hs, /home/hecate/Contrib/cabal/dist-newstyle/build/x86_64-linux/ghc-9.4.4/Cabal-syntax-3.11.0.0/build/Distribution/Compat/Exception.o, /home/hecate/Contrib/cabal/dist-newstyle/build/x86_64-linux/ghc-9.4.4/Cabal-syntax-3.11.0.0/build/Distribution/Compat/Exception.dyn_o )
[  3 of 137] Compiling Distribution.Compat.MonadFail ( src/Distribution/Compat/MonadFail.hs, /home/hecate/Contrib/cabal/dist-newstyle/build/x86_64-linux/ghc-9.4.4/Cabal-syntax-3.11.0.0/build/Distribution/Compat/MonadFail.o, /home/hecate/Contrib/cabal/dist-newstyle/build/x86_64-linux/ghc-9.4.4/Cabal-syntax-3.11.0.0/build/Distribution/Compat/MonadFail.dyn_o )
Progress: [ 2%] [##..................................................................................................] 

Personally I think it would be a nice breeze of fresh air, and perhaps also the opportunity to declutter the default output. The current output could be still made available if the terminal declares not to support ANSI or be "tty".


Implementation

There is a library that implements such spinners (spin) which we can easily vendor since it's quite stable and very small.

ulysses4ever commented 1 year ago

I was thinking about a progress bar like that for cabal update: it’s killing me how it just freezes for a minute not saying anything! Build at least shows something… But yeah, that would be nice to have for build too.

Kleidukos commented 1 year ago

Ah yeah I understand the frustration. :)

michaelpj commented 1 year ago

Just thinking: we probably want to show progress through packages and also progress within a package. I think that's not too bad as you can just subdivide the progress bar for each package and then subdivide those for each module (say). That should work with parallelism also.

An alternative to a progress bar is a display of job counts <completed>/<in-progress>/<todo>, which also has the advantage of showing how many jobs are in progress, which can be nice to see. This probably fails for single-package progress, though.