Skip to content

Commit

Permalink
-r for "deps"
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Mar 10, 2011
1 parent 1efe523 commit a1f6825
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Commands.hs
Expand Up @@ -20,7 +20,7 @@ deps _ nmver flags = do
then return db'
else toPkgDB . flip toPkgList db' <$> userPkgs
pkg <- lookupPkg nmver db
printDeps pkg db
printDeps (recursiveFlag flags) db 0 pkg

revdeps :: FunctionCommand
revdeps _ nmver _ = do
Expand Down
15 changes: 10 additions & 5 deletions PkgDB.hs
@@ -1,5 +1,6 @@
module PkgDB where

import Control.Monad
import Distribution.Version
(Version(..))
import Distribution.InstalledPackageInfo
Expand Down Expand Up @@ -79,10 +80,14 @@ idOfPkgInfo = sourcePackageId

----------------------------------------------------------------

printDeps :: PkgInfo -> PkgDB -> IO ()
printDeps pkgi db = mapM_ (printDep db) $ depends pkgi
printDeps :: Bool -> PkgDB -> Int -> PkgInfo -> IO ()
printDeps rec db n pkgi = mapM_ (printDep rec db n) $ depends pkgi

printDep :: PkgDB -> InstalledPackageId -> IO ()
printDep db pid = case lookupInstalledPackageId db pid of
printDep :: Bool -> PkgDB -> Int -> InstalledPackageId -> IO ()
printDep rec db n pid = case lookupInstalledPackageId db pid of
Nothing -> return ()
Just pkgi -> putStrLn $ nameOfPkgInfo pkgi
Just pkgi -> do
putStrLn $ prefix ++ nameOfPkgInfo pkgi
when rec $ printDeps rec db (n+1) pkgi
where
prefix = replicate (n * 4) ' '

0 comments on commit a1f6825

Please sign in to comment.