haskell / cabal

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

cabal list should also list installed packages #228

Closed bos closed 12 years ago

bos commented 12 years ago

(Imported from Trac #235, reported by @dcoutts on 2008-02-11)

Currently cabal list foo only looks at the available packages and not at the installed ones.

The cabal list command output needs improving. It currently lists all available versions of available (but not installed) packages. That's both too much and too little info. We want to know for each matching package the installed versions and we probably do not need to know every single available version.

There are already RepoIndex and LocalIndex types for doing lookups so this task is just to format the information nicely. See the Hackage.List module in cabal-install.

For reference you might like to look at what other similar tools do. For example Gentoo's esearch utility gives us:

$ esearch xmonad
[ Results for search key : xmonad ]
[ Applications found : 2 ]
*  x11-wm/xmonad
      Latest version available: 0.5-r1
      Latest version installed: 0.5
      Size of downloaded files: [no/bad digest]
      Homepage:    http://www.xmonad.org/
      Description: A lightweight X11 window manager
      License:     BSD
*  x11-wm/xmonad-contrib
      Latest version available: 0.5-r1
      Latest version installed: [ Not Installed ]
      Size of downloaded files: [no/bad digest]
      Homepage:    http://www.xmonad.org/
      Description: Third party extentions for xmonad
      License:     BSD
bos commented 12 years ago

(Imported comment by @dcoutts on 2008-02-11)

Thanks to Kolmodin's patches the output now looks like:

$ cabal list xmo
 * xmobar
      Latest version available: 0.8
      Homepage: http://gorgias.mine.nu/repos/xmobar/
      Category: System
      Synopsis: A Statusbar for the XMonad Window Manager
      License:  BSD3
 * xmonad
      Latest version available: 0.6
      Latest version installed: 0.6
      Category: System
      Synopsis: A lightweight X11 window manager.
      License:  BSD3
 * xmonad-contrib
      Latest version available: 0.6
      Homepage: http://xmonad.org/
      Category: System
      Synopsis: Third party extensions for xmonad
      License:  BSD3
Or just listing installed packages:
$ cabal list xmo --installed
 * xmonad
      Latest version available: 0.6
      Latest version installed: 0.6
      Category: System
      Synopsis: A lightweight X11 window manager.
      License:  BSD3
And the machine readable output:
$ cabal list xmo --simple-output
xmobar 0.3
xmobar 0.3.1
xmobar 0.4
xmobar 0.5
xmobar 0.6
xmobar 0.7
xmobar 0.8
xmonad 0.1
xmonad 0.2
xmonad 0.3
xmonad 0.4
xmonad 0.4.1
xmonad 0.5
xmonad 0.6
xmonad-contrib 0.5
xmonad-contrib 0.6
$ cabal list xmo --simple-output --installed
xmonad 0.5
xmonad 0.6