Commit c0537226 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Add flag --print-id for ./Setup register, outputs installed package ID


Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 47984faa
......@@ -85,6 +85,7 @@ import System.FilePath ((</>), (<.>), isAbsolute)
import System.Directory
( getCurrentDirectory, removeDirectoryRecursive )
import Control.Monad (when)
import Data.Maybe
( isJust, fromMaybe, maybeToList )
import Data.List
......@@ -103,6 +104,9 @@ register pkg@PackageDescription { library = Just lib } lbi regFlags
installedPkgInfo <- generateRegistrationInfo
verbosity pkg lib lbi clbi inplace distPref
when (fromFlag (regPrintId regFlags)) $ do
putStrLn (display (IPI.installedPackageId installedPkgInfo))
-- Three different modes:
case () of
_ | modeGenerateRegFile -> writeRegistrationFile installedPkgInfo
......
......@@ -929,6 +929,7 @@ data RegisterFlags = RegisterFlags {
regGenPkgConf :: Flag (Maybe FilePath),
regInPlace :: Flag Bool,
regDistPref :: Flag FilePath,
regPrintId :: Flag Bool,
regVerbosity :: Flag Verbosity
}
deriving Show
......@@ -940,6 +941,7 @@ defaultRegisterFlags = RegisterFlags {
regGenPkgConf = NoFlag,
regInPlace = Flag False,
regDistPref = Flag defaultDistPref,
regPrintId = Flag False,
regVerbosity = Flag normal
}
......@@ -977,6 +979,11 @@ registerCommand = makeCommand name shortDesc longDesc
"instead of registering, generate a package registration file"
regGenPkgConf (\v flags -> flags { regGenPkgConf = v })
(optArg' "PKG" Flag flagToList)
,option "" ["print-ipid"]
"print the installed package ID calculated for this package"
regPrintId (\v flags -> flags { regPrintId = v })
trueArg
]
unregisterCommand :: CommandUI RegisterFlags
......@@ -1014,6 +1021,7 @@ instance Monoid RegisterFlags where
regGenScript = mempty,
regGenPkgConf = mempty,
regInPlace = mempty,
regPrintId = mempty,
regDistPref = mempty,
regVerbosity = mempty
}
......@@ -1022,6 +1030,7 @@ instance Monoid RegisterFlags where
regGenScript = combine regGenScript,
regGenPkgConf = combine regGenPkgConf,
regInPlace = combine regInPlace,
regPrintId = combine regPrintId,
regDistPref = combine regDistPref,
regVerbosity = combine regVerbosity
}
......
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