git-annex/Types/StandardGroups.hs

42 lines
1.9 KiB
Haskell
Raw Normal View History

2012-10-10 19:15:56 +00:00
{- git-annex standard repository groups
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Types.StandardGroups where
2012-11-24 20:30:15 +00:00
data StandardGroup = ClientGroup | TransferGroup | BackupGroup | SmallArchiveGroup | FullArchiveGroup
deriving (Eq, Ord, Enum, Bounded, Show)
2012-10-10 19:15:56 +00:00
fromStandardGroup :: StandardGroup -> String
fromStandardGroup ClientGroup = "client"
fromStandardGroup TransferGroup = "transfer"
fromStandardGroup BackupGroup = "backup"
2012-11-24 20:30:15 +00:00
fromStandardGroup SmallArchiveGroup = "smallarchive"
fromStandardGroup FullArchiveGroup = "archive"
2012-10-10 19:15:56 +00:00
toStandardGroup :: String -> Maybe StandardGroup
toStandardGroup "client" = Just ClientGroup
toStandardGroup "transfer" = Just TransferGroup
toStandardGroup "backup" = Just BackupGroup
2012-11-24 20:30:15 +00:00
toStandardGroup "smallarchive" = Just SmallArchiveGroup
toStandardGroup "archive" = Just FullArchiveGroup
2012-10-10 19:15:56 +00:00
toStandardGroup _ = Nothing
descStandardGroup :: StandardGroup -> String
descStandardGroup ClientGroup = "client: a repository on your computer"
2012-10-10 20:23:41 +00:00
descStandardGroup TransferGroup = "transfer: distributes files to clients"
2012-11-24 20:30:15 +00:00
descStandardGroup BackupGroup = "backup: backs up all files"
descStandardGroup SmallArchiveGroup = "small archive: archives files located in \"archive\" directories"
descStandardGroup FullArchiveGroup = "full archive: archives all files not archived elsewhere"
2012-10-10 19:15:56 +00:00
{- See doc/preferred_content.mdwn for explanations of these expressions. -}
preferredContent :: StandardGroup -> String
2012-11-24 20:30:15 +00:00
preferredContent ClientGroup = "exclude=*/archive/* and exclude=archive/*"
2012-10-14 20:21:18 +00:00
preferredContent TransferGroup = "not (inallgroup=client and copies=client:2) and " ++ preferredContent ClientGroup
preferredContent BackupGroup = "include=*"
2012-11-24 20:30:15 +00:00
preferredContent SmallArchiveGroup = "(include=*/archive/* or include=archive/*) and " ++ preferredContent FullArchiveGroup
preferredContent FullArchiveGroup = "not (copies=archive:1 or copies=smallarchive:1)"