summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2007-09-07 18:19:44 +0000
committerIan Lynagh <igloo@earth.li>2007-09-07 18:19:44 +0000
commit2c23d7c5f5155b950ffab85ef9ab037932c938a9 (patch)
treee821ab02413123f2012c36cf6766265fed8ab97f /utils
parent3b1438a9757639d7f37f10e1237e2369ca0ebe4a (diff)
downloadhaskell-2c23d7c5f5155b950ffab85ef9ab037932c938a9.tar.gz
Add a --names-only flag for list --simple-output
We use this in the testsuite to find out which libraries we should run the tests from.
Diffstat (limited to 'utils')
-rw-r--r--utils/ghc-pkg/Main.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index 02370e27a7..8c106b038d 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -99,6 +99,7 @@ data Flag
| FlagAutoGHCiLibs
| FlagDefinedName String String
| FlagSimpleOutput
+ | FlagNamesOnly
deriving Eq
flags :: [OptDescr Flag]
@@ -124,7 +125,9 @@ flags = [
Option ['V'] ["version"] (NoArg FlagVersion)
"output version information and exit",
Option [] ["simple-output"] (NoArg FlagSimpleOutput)
- "print output in easy-to-parse format for some commands"
+ "print output in easy-to-parse format for some commands",
+ Option [] ["names-only"] (NoArg FlagNamesOnly)
+ "only print package names, not versions; can only be used with list --simple-output"
]
where
toDefined str =
@@ -491,7 +494,9 @@ listPackages flags mPackageName = do
where doc = text (showPackageId (package p))
show_simple db_stack = do
- let pkgs = map showPackageId $ sortBy compPkgIdVer $
+ let showPkg = if FlagNamesOnly `elem` flags then pkgName
+ else showPackageId
+ pkgs = map showPkg $ sortBy compPkgIdVer $
map package (concatMap snd db_stack)
when (null pkgs) $ die "no matches"
hPutStrLn stdout $ concat $ intersperse " " pkgs