2014-01-26 20:37:27 +00:00
|
|
|
{- git-annex-shell fields
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2012 Joey Hess <id@joeyh.name>
|
2014-01-26 20:37:27 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2014-01-26 20:37:27 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
module CmdLine.GitAnnexShell.Fields where
|
|
|
|
|
2016-01-20 20:36:33 +00:00
|
|
|
import Annex.Common
|
2014-01-26 20:37:27 +00:00
|
|
|
import qualified Annex
|
|
|
|
|
|
|
|
import Data.Char
|
|
|
|
|
|
|
|
{- A field, stored in Annex state, with a value sanity checker. -}
|
|
|
|
data Field = Field
|
|
|
|
{ fieldName :: String
|
|
|
|
, fieldCheck :: String -> Bool
|
|
|
|
}
|
|
|
|
|
|
|
|
getField :: Field -> Annex (Maybe String)
|
|
|
|
getField = Annex.getField . fieldName
|
|
|
|
|
|
|
|
remoteUUID :: Field
|
|
|
|
remoteUUID = Field "remoteuuid" $
|
|
|
|
-- does it look like a UUID?
|
|
|
|
all (\c -> isAlphaNum c || c == '-')
|
|
|
|
|
2015-12-26 17:59:27 +00:00
|
|
|
unlocked :: Field
|
|
|
|
unlocked = Field "unlocked" $ \f -> f == "1"
|
|
|
|
|
2015-08-05 17:49:54 +00:00
|
|
|
autoInit :: Field
|
|
|
|
autoInit = Field "autoinit" $ \f -> f == "1"
|