From 2c23d7c5f5155b950ffab85ef9ab037932c938a9 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 7 Sep 2007 18:19:44 +0000 Subject: [PATCH] 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. --- utils/ghc-pkg/Main.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs index 02370e2..8c106b0 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 -- 1.7.10.4