2011-03-19 18:33:24 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2010 Joey Hess <id@joeyh.name>
|
2011-03-19 18:33:24 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Version where
|
|
|
|
|
|
|
|
import Command
|
2011-08-20 20:11:42 +00:00
|
|
|
import qualified Build.SysConfig as SysConfig
|
2011-10-04 04:40:47 +00:00
|
|
|
import Annex.Version
|
2017-04-07 22:03:09 +00:00
|
|
|
import BuildInfo
|
2017-02-24 19:16:56 +00:00
|
|
|
import Types.Key
|
2013-10-02 00:50:46 +00:00
|
|
|
import qualified Types.Backend as B
|
|
|
|
import qualified Types.Remote as R
|
|
|
|
import qualified Remote
|
|
|
|
import qualified Backend
|
2011-03-19 18:33:24 +00:00
|
|
|
|
2016-05-05 20:06:01 +00:00
|
|
|
import System.Info
|
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2015-07-10 17:49:46 +00:00
|
|
|
cmd = dontCheck repoExists $ noCommit $
|
|
|
|
noRepo (seekNoRepo <$$> optParser) $
|
2015-07-08 19:39:05 +00:00
|
|
|
command "version" SectionQuery "show version info"
|
2015-07-10 17:49:46 +00:00
|
|
|
paramNothing (seek <$$> optParser)
|
2011-03-19 18:33:24 +00:00
|
|
|
|
2015-07-10 17:49:46 +00:00
|
|
|
data VersionOptions = VersionOptions
|
|
|
|
{ rawOption :: Bool
|
|
|
|
}
|
2015-04-02 19:37:39 +00:00
|
|
|
|
2015-07-10 17:49:46 +00:00
|
|
|
optParser :: CmdParamsDesc -> Parser VersionOptions
|
|
|
|
optParser _ = VersionOptions
|
|
|
|
<$> switch
|
|
|
|
( long "raw"
|
|
|
|
<> help "output only program version"
|
|
|
|
)
|
2015-04-02 19:37:39 +00:00
|
|
|
|
2015-07-10 17:49:46 +00:00
|
|
|
seek :: VersionOptions -> CommandSeek
|
|
|
|
seek o
|
|
|
|
| rawOption o = liftIO showRawVersion
|
|
|
|
| otherwise = showVersion
|
|
|
|
|
|
|
|
seekNoRepo :: VersionOptions -> IO ()
|
|
|
|
seekNoRepo o
|
|
|
|
| rawOption o = showRawVersion
|
|
|
|
| otherwise = showPackageVersion
|
2011-03-19 18:33:24 +00:00
|
|
|
|
2015-07-10 17:49:46 +00:00
|
|
|
showVersion :: Annex ()
|
|
|
|
showVersion = do
|
2011-03-19 18:33:24 +00:00
|
|
|
v <- getVersion
|
2011-10-31 20:46:51 +00:00
|
|
|
liftIO $ do
|
2011-11-16 04:49:09 +00:00
|
|
|
showPackageVersion
|
2015-07-09 20:05:45 +00:00
|
|
|
vinfo "local repository version" $ fromMaybe "unknown" v
|
2015-12-04 20:14:48 +00:00
|
|
|
vinfo "supported repository versions" $
|
|
|
|
unwords supportedVersions
|
2015-07-09 20:05:45 +00:00
|
|
|
vinfo "upgrade supported from repository versions" $
|
2013-10-02 00:50:46 +00:00
|
|
|
unwords upgradableVersions
|
2016-05-05 20:06:01 +00:00
|
|
|
vinfo "operating system" $
|
|
|
|
unwords [os, arch]
|
2013-11-30 19:18:40 +00:00
|
|
|
|
2011-11-16 04:49:09 +00:00
|
|
|
showPackageVersion :: IO ()
|
2013-05-02 03:11:13 +00:00
|
|
|
showPackageVersion = do
|
2015-07-09 20:05:45 +00:00
|
|
|
vinfo "git-annex version" SysConfig.packageversion
|
|
|
|
vinfo "build flags" $ unwords buildFlags
|
2017-04-07 22:03:09 +00:00
|
|
|
vinfo "dependency versions" $ unwords dependencyVersions
|
2017-02-24 19:16:56 +00:00
|
|
|
vinfo "key/value backends" $ unwords $
|
|
|
|
map (formatKeyVariety . B.backendVariety) Backend.list
|
2015-07-09 20:05:45 +00:00
|
|
|
vinfo "remote types" $ unwords $ map R.typename Remote.remoteTypes
|
2013-10-02 00:50:46 +00:00
|
|
|
|
2015-07-10 17:49:46 +00:00
|
|
|
showRawVersion :: IO ()
|
|
|
|
showRawVersion = do
|
|
|
|
putStr SysConfig.packageversion
|
|
|
|
hFlush stdout -- no newline, so flush
|
|
|
|
|
2015-07-09 20:05:45 +00:00
|
|
|
vinfo :: String -> String -> IO ()
|
|
|
|
vinfo k v = putStrLn $ k ++ ": " ++ v
|