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
|
|
|
|
|
2011-10-05 20:02:51 +00:00
|
|
|
import Common.Annex
|
2011-03-19 18:33:24 +00:00
|
|
|
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
|
2013-03-09 18:57:23 +00:00
|
|
|
import BuildFlags
|
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
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
|
|
|
cmd = withOptions [rawOption] $
|
2015-04-02 19:37:39 +00:00
|
|
|
noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
2015-07-08 19:08:02 +00:00
|
|
|
command "version" SectionQuery "show version info"
|
|
|
|
paramNothing (withParams seek)
|
2011-03-19 18:33:24 +00:00
|
|
|
|
2015-04-02 19:37:39 +00:00
|
|
|
rawOption :: Option
|
|
|
|
rawOption = flagOption [] "raw" "output only program version"
|
|
|
|
|
2015-07-08 19:08:02 +00:00
|
|
|
seek :: CmdParams -> CommandSeek
|
2015-04-02 19:37:39 +00:00
|
|
|
seek = withNothing $ ifM (getOptionFlag rawOption) (startRaw, start)
|
|
|
|
|
|
|
|
startRaw :: CommandStart
|
|
|
|
startRaw = do
|
|
|
|
liftIO $ do
|
|
|
|
putStr SysConfig.packageversion
|
|
|
|
hFlush stdout
|
|
|
|
stop
|
2011-03-19 18:33:24 +00:00
|
|
|
|
2011-09-15 20:50:49 +00:00
|
|
|
start :: CommandStart
|
2011-03-19 18:33:24 +00:00
|
|
|
start = do
|
|
|
|
v <- getVersion
|
2011-10-31 20:46:51 +00:00
|
|
|
liftIO $ do
|
2015-04-02 19:37:39 +00:00
|
|
|
|
2011-11-16 04:49:09 +00:00
|
|
|
showPackageVersion
|
2013-10-02 00:50:46 +00:00
|
|
|
info "local repository version" $ fromMaybe "unknown" v
|
2013-12-29 17:06:23 +00:00
|
|
|
info "supported repository version" supportedVersion
|
2013-10-02 00:50:46 +00:00
|
|
|
info "upgrade supported from repository versions" $
|
|
|
|
unwords upgradableVersions
|
2012-02-14 16:40:40 +00:00
|
|
|
stop
|
2011-11-16 04:49:09 +00:00
|
|
|
|
2013-11-30 19:18:40 +00:00
|
|
|
startNoRepo :: CmdParams -> IO ()
|
|
|
|
startNoRepo _ = showPackageVersion
|
|
|
|
|
2011-11-16 04:49:09 +00:00
|
|
|
showPackageVersion :: IO ()
|
2013-05-02 03:11:13 +00:00
|
|
|
showPackageVersion = do
|
2013-10-02 00:50:46 +00:00
|
|
|
info "git-annex version" SysConfig.packageversion
|
|
|
|
info "build flags" $ unwords buildFlags
|
|
|
|
info "key/value backends" $ unwords $ map B.name Backend.list
|
|
|
|
info "remote types" $ unwords $ map R.typename Remote.remoteTypes
|
|
|
|
|
|
|
|
info :: String -> String -> IO ()
|
|
|
|
info k v = putStrLn $ k ++ ": " ++ v
|