X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fghc-pkg%2FMain.hs;h=8c106b038da838ecb2e0567087db16586c410ec0;hb=a6e4ca6e55cfc3f3fd3253df69e803c8a999729a;hp=02370e27a7218a59c5a6c80eee4db1fca2ccb2da;hpb=395726c5f8e77a01074e775e838658243e39e21c;p=ghc-hetmet.git 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