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
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2011-03-19 18:33:24 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Version where
|
|
|
|
|
|
|
|
import Command
|
2011-10-04 04:40:47 +00:00
|
|
|
import Annex.Version
|
2017-04-07 22:03:09 +00:00
|
|
|
import BuildInfo
|
2018-01-02 17:47:51 +00:00
|
|
|
import BuildFlags
|
2017-02-24 19:16:56 +00:00
|
|
|
import Types.Key
|
2018-10-25 21:23:53 +00:00
|
|
|
import Types.RepoVersion
|
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
|
2018-06-04 16:26:18 +00:00
|
|
|
liftIO showPackageVersion
|
2018-10-25 21:23:53 +00:00
|
|
|
maybe noop (liftIO . vinfo "local repository version" . showRepoVersion)
|
2018-06-04 16:26:18 +00:00
|
|
|
=<< getVersion
|
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
|
2017-12-14 16:46:57 +00:00
|
|
|
vinfo "git-annex version" BuildInfo.packageversion
|
2015-07-09 20:05:45 +00:00
|
|
|
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 $
|
2019-01-11 20:34:04 +00:00
|
|
|
map (decodeBS . formatKeyVariety . B.backendVariety) Backend.list
|
2015-07-09 20:05:45 +00:00
|
|
|
vinfo "remote types" $ unwords $ map R.typename Remote.remoteTypes
|
2018-06-04 16:26:18 +00:00
|
|
|
vinfo "operating system" $ unwords [os, arch]
|
|
|
|
vinfo "supported repository versions" $
|
2018-10-25 21:23:53 +00:00
|
|
|
verlist supportedVersions
|
2018-06-04 16:26:18 +00:00
|
|
|
vinfo "upgrade supported from repository versions" $
|
2018-10-25 21:23:53 +00:00
|
|
|
verlist upgradableVersions
|
|
|
|
where
|
|
|
|
verlist = unwords . map showRepoVersion
|
|
|
|
|
|
|
|
showRepoVersion :: RepoVersion -> String
|
|
|
|
showRepoVersion = show . fromRepoVersion
|
2013-10-02 00:50:46 +00:00
|
|
|
|
2015-07-10 17:49:46 +00:00
|
|
|
showRawVersion :: IO ()
|
|
|
|
showRawVersion = do
|
2017-12-14 16:46:57 +00:00
|
|
|
putStr BuildInfo.packageversion
|
2015-07-10 17:49:46 +00:00
|
|
|
hFlush stdout -- no newline, so flush
|
|
|
|
|
2015-07-09 20:05:45 +00:00
|
|
|
vinfo :: String -> String -> IO ()
|
|
|
|
vinfo k v = putStrLn $ k ++ ": " ++ v
|