Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

41 lines (33 sloc) 1.129 kb
{- |
Module : Main
Description : The haskell-updater executable
License : GPL-2 or later
Fancy output facility.
-}
module Output (
pkgListPrint
, printList
, say
, Verbosity(..)
) where
import System.IO (hPutStrLn, stderr)
import Distribution.Gentoo.Packages
-- output mode (chattiness)
data Verbosity = Normal
| Quiet
deriving (Eq, Ord, Show, Read)
say :: Verbosity -> String -> IO ()
say Normal msg = hPutStrLn stderr msg
say Quiet _msg = return ()
-- Print a bullet list of values with one value per line.
printList :: Verbosity -> (a -> String) -> [a] -> IO ()
printList v f = mapM_ (say v . (++) " * " . f)
-- Print a list of packages, with a description of what they are.
pkgListPrint :: Verbosity -> String -> [Package] -> IO ()
pkgListPrint v desc pkgs
= if null pkgs
then say v $ unwords ["No", desc, "packages found!\n"]
else do say v $ unwords ["Found the following"
, desc, "packages:"]
printList v printPkg pkgs
say v ""
Jump to Line
Something went wrong with that request. Please try again.