Commit 68deddde authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Merge pull request #1599 from wdanilo/master

Refactoring: extracting 'List.getPkgList' function out of 'List.list'
parents 1d8ae56f a682875c
...@@ -70,17 +70,16 @@ import System.Directory ...@@ -70,17 +70,16 @@ import System.Directory
( doesDirectoryExist ) ( doesDirectoryExist )
-- |Show information about packages -- |Returns list of packages matching a search strings
list :: Verbosity getPkgList :: Verbosity
-> PackageDBStack -> PackageDBStack
-> [Repo] -> [Repo]
-> Compiler -> Compiler
-> ProgramConfiguration -> ProgramConfiguration
-> ListFlags -> ListFlags
-> [String] -> [String]
-> IO () -> IO [PackageDisplayInfo]
list verbosity packageDBs repos comp conf listFlags pats = do getPkgList verbosity packageDBs repos comp conf listFlags pats = do
installedPkgIndex <- getInstalledPackages verbosity comp packageDBs conf installedPkgIndex <- getInstalledPackages verbosity comp packageDBs conf
sourcePkgDb <- getSourcePackages verbosity repos sourcePkgDb <- getSourcePackages verbosity repos
let sourcePkgIndex = packageIndex sourcePkgDb let sourcePkgIndex = packageIndex sourcePkgDb
...@@ -104,6 +103,26 @@ list verbosity packageDBs repos comp conf listFlags pats = do ...@@ -104,6 +103,26 @@ list verbosity packageDBs repos comp conf listFlags pats = do
, not onlyInstalled || not (null installedPkgs) , not onlyInstalled || not (null installedPkgs)
, let pref = prefs pkgname , let pref = prefs pkgname
selectedPkg = latestWithPref pref sourcePkgs ] selectedPkg = latestWithPref pref sourcePkgs ]
return matches
where
onlyInstalled = fromFlag (listInstalled listFlags)
matchingPackages search index =
[ pkg
| pat <- pats
, pkg <- search index pat ]
-- |Show information about packages
list :: Verbosity
-> PackageDBStack
-> [Repo]
-> Compiler
-> ProgramConfiguration
-> ListFlags
-> [String]
-> IO ()
list verbosity packageDBs repos comp conf listFlags pats = do
matches <- getPkgList verbosity packageDBs repos comp conf listFlags pats
if simpleOutput if simpleOutput
then putStr $ unlines then putStr $ unlines
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment