skeleton of filter-branch command, with option parser

This commit is contained in:
Joey Hess 2021-05-14 10:59:48 -04:00
parent a71c002ac1
commit a58c90ccf4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 88 additions and 4 deletions

78
Command/FilterBranch.hs Normal file
View file

@ -0,0 +1,78 @@
{- git-annex command
-
- Copyright 2021 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Command.FilterBranch where
import Command
cmd :: Command
cmd = withGlobalOptions [annexedMatchingOptions] $
command "filter-branch" SectionMaintenance
"filter information from the git-annex branch"
paramPaths (seek <$$> optParser)
data FilterBranchOptions = FilterBranchOptions
{ includeFiles :: CmdParams
, keyOptions :: Maybe KeyOptions
, includeKeyInformationFor :: [DeferredParse UUID]
, excludeKeyInformationFor :: [DeferredParse UUID]
, includeAllKeyInformation :: Bool
, includeRepoConfigFor :: [DeferredParse UUID]
, excludeRepoConfigFor :: [DeferredParse UUID]
, includeAllRemoteConfig :: Bool
, includeGlobalConfig :: Bool
, excludeGlobalConfig :: Bool
}
optParser :: CmdParamsDesc -> Parser FilterBranchOptions
optParser desc = FilterBranchOptions
<$> cmdParams desc
<*> optional parseKeyOptions
<*> many
( parseRepositoryOption "include-key-information-for"
"include key information for a repository"
)
<*> many
( parseRepositoryOption "exclude-key-information-for"
"exclude key information for a repository"
)
<*> switch
( long "include-all-key-information"
<> help "include key information for all repositories"
)
<*> many
( parseRepositoryOption "include-repo-config-for"
"include configuration specific to a repository"
)
<*> many
( parseRepositoryOption "exclude-repo-config-for"
"exclude configuration specific to a repository"
)
<*> switch
( long "include-all-repo-config"
<> help "include configuration of all repositories"
)
<*> switch
( long "include-global-config"
<> help "include global configuration"
)
<*> switch
( long "exclude-global-config"
<> help "exclude global configuration"
)
parseRepositoryOption :: String -> String -> Parser (DeferredParse UUID)
parseRepositoryOption s h = parseUUIDOption <$> strOption
( long s
<> metavar (paramRemote `paramOr` paramDesc `paramOr` paramUUID)
<> help h
<> completeRemotes
)
seek :: FilterBranchOptions -> CommandSeek
seek o = do
error "TODO"