finished converting all the main options

This commit is contained in:
Joey Hess 2015-07-10 13:18:46 -04:00
parent 5cc882a35e
commit 6a4f2087be
22 changed files with 165 additions and 122 deletions

View file

@ -35,28 +35,34 @@ import Utility.Tmp
import Control.Exception (IOException)
cmd :: Command
cmd = notBareRepo $ withOptions addOptions $
cmd = notBareRepo $ withGlobalOptions fileMatchingOptions $
command "add" SectionCommon "add files to annex"
paramPaths (withParams seek)
paramPaths (seek <$$> optParser)
addOptions :: [Option]
addOptions = includeDotFilesOption : fileMatchingOptions
data AddOptions = AddOptions
{ addThese :: CmdParams
, includeDotFiles :: Bool
}
includeDotFilesOption :: Option
includeDotFilesOption = flagOption [] "include-dotfiles" "don't skip dotfiles"
optParser :: CmdParamsDesc -> Parser AddOptions
optParser desc = AddOptions
<$> cmdParams desc
<*> switch
( long "include-dotfiles"
<> help "don't skip dotfiles"
)
{- Add acts on both files not checked into git yet, and unlocked files.
-
- In direct mode, it acts on any files that have changed. -}
seek :: CmdParams -> CommandSeek
seek ps = do
seek :: AddOptions -> CommandSeek
seek o = do
matcher <- largeFilesMatcher
let go a = flip a ps $ \file -> ifM (checkFileMatcher matcher file <||> Annex.getState Annex.force)
let go a = flip a (addThese o) $ \file -> ifM (checkFileMatcher matcher file <||> Annex.getState Annex.force)
( start file
, startSmall file
)
skipdotfiles <- not <$> Annex.getFlag (optionName includeDotFilesOption)
go $ withFilesNotInGit skipdotfiles
go $ withFilesNotInGit (not $ includeDotFiles o)
ifM isDirect
( go withFilesMaybeModified
, go withFilesUnlocked

View file

@ -23,9 +23,10 @@ import Annex.Notification
import qualified Data.Set as S
cmd :: Command
cmd = command "drop" SectionCommon
"remove content of files from repository"
paramPaths (seek <$$> optParser)
cmd = withGlobalOptions annexedMatchingOptions $
command "drop" SectionCommon
"remove content of files from repository"
paramPaths (seek <$$> optParser)
data DropOptions = DropOptions
{ dropFiles :: CmdParams
@ -34,8 +35,6 @@ data DropOptions = DropOptions
, keyOptions :: Maybe KeyOptions
}
-- TODO: annexedMatchingOptions
optParser :: CmdParamsDesc -> Parser DropOptions
optParser desc = DropOptions
<$> cmdParams desc

View file

@ -19,7 +19,7 @@ import Utility.DataUnits
import Types.Key
cmd :: Command
cmd = withOptions annexedMatchingOptions $ mkCommand $
cmd = withGlobalOptions annexedMatchingOptions $ mkCommand $
command "find" SectionQuery "lists available files"
paramPaths (seek <$$> optParser)

View file

@ -19,7 +19,7 @@ import Utility.Touch
#endif
cmd :: Command
cmd = notDirect $ noCommit $ withOptions annexedMatchingOptions $
cmd = notDirect $ noCommit $ withGlobalOptions annexedMatchingOptions $
command "fix" SectionMaintenance
"fix up symlinks to point to annexed content"
paramPaths (withParams seek)

View file

@ -41,9 +41,10 @@ import Data.Time.Clock.POSIX
import System.Posix.Types (EpochTime)
cmd :: Command
cmd = command "fsck" SectionMaintenance
"find and fix problems"
paramPaths (seek <$$> optParser)
cmd = withGlobalOptions annexedMatchingOptions $
command "fsck" SectionMaintenance
"find and fix problems"
paramPaths (seek <$$> optParser)
data FsckOptions = FsckOptions
{ fsckFiles :: CmdParams
@ -52,8 +53,6 @@ data FsckOptions = FsckOptions
, keyOptions :: Maybe KeyOptions
}
-- TODO: annexedMatchingOptions
data IncrementalOpt
= StartIncrementalO
| MoreIncrementalO

View file

@ -17,9 +17,10 @@ import Annex.Wanted
import qualified Command.Move
cmd :: Command
cmd = command "get" SectionCommon
"make content of annexed files available"
paramPaths (seek <$$> optParser)
cmd = withGlobalOptions (jobsOption : annexedMatchingOptions) $
command "get" SectionCommon
"make content of annexed files available"
paramPaths (seek <$$> optParser)
data GetOptions = GetOptions
{ getFiles :: CmdParams
@ -35,8 +36,6 @@ optParser desc = GetOptions
<*> parseAutoOption
<*> optional (parseKeyOptions True)
-- TODO: jobsOption, annexedMatchingOptions
seek :: GetOptions -> CommandSeek
seek o = do
from <- maybe (pure Nothing) (Just <$$> getParsed) (getFrom o)

View file

@ -28,7 +28,7 @@ cmd = withOptions opts $ notBareRepo $
"move and add files from outside git working copy"
paramPaths (withParams seek)
opts :: [Option]
opts :: [GlobalOption]
opts = duplicateModeOptions ++ fileMatchingOptions
data DuplicateMode = Default | Duplicate | DeDuplicate | CleanDuplicates | SkipDuplicates

View file

@ -13,7 +13,7 @@ import qualified Annex.Queue
import qualified Annex
cmd :: Command
cmd = notDirect $ withOptions annexedMatchingOptions $
cmd = notDirect $ withGlobalOptions annexedMatchingOptions $
command "lock" SectionCommon
"undo unlock command"
paramPaths (withParams seek)

View file

@ -39,11 +39,11 @@ data RefChange = RefChange
type Outputter = Bool -> POSIXTime -> [UUID] -> Annex ()
cmd :: Command
cmd = withOptions options $
cmd = withGlobalOptions options $
command "log" SectionQuery "shows location log"
paramPaths (withParams seek)
options :: [Option]
options :: [GlobalOption]
options = passthruOptions ++ [gourceOption] ++ annexedMatchingOptions
passthruOptions :: [Option]

View file

@ -19,7 +19,7 @@ import qualified Command.Fsck
import qualified Annex
cmd :: Command
cmd = notDirect $ withOptions annexedMatchingOptions $
cmd = notDirect $ withGlobalOptions annexedMatchingOptions $
command "migrate" SectionUtility
"switch data to different backend"
paramPaths (withParams seek)

View file

@ -18,9 +18,10 @@ import Annex.Transfer
import Logs.Presence
cmd :: Command
cmd = command "move" SectionCommon
"move content of files to/from another repository"
paramPaths (seek <--< optParser)
cmd = withGlobalOptions (jobsOption : annexedMatchingOptions) $
command "move" SectionCommon
"move content of files to/from another repository"
paramPaths (seek <--< optParser)
data MoveOptions = MoveOptions
{ moveFiles :: CmdParams
@ -28,8 +29,6 @@ data MoveOptions = MoveOptions
, keyOptions :: Maybe KeyOptions
}
-- TODO: jobsOption, annexedMatchingOptions
optParser :: CmdParamsDesc -> Parser MoveOptions
optParser desc = MoveOptions
<$> cmdParams desc

View file

@ -23,7 +23,7 @@ import Utility.CopyFile
import Command.PreCommit (lockPreCommitHook)
cmd :: Command
cmd = withOptions annexedMatchingOptions $
cmd = withGlobalOptions annexedMatchingOptions $
command "unannex" SectionUtility
"undo accidential add command"
paramPaths (withParams seek)

View file

@ -20,7 +20,7 @@ editcmd :: Command
editcmd = mkcmd "edit" "same as unlock"
mkcmd :: String -> String -> Command
mkcmd n d = notDirect $ withOptions annexedMatchingOptions $
mkcmd n d = notDirect $ withGlobalOptions annexedMatchingOptions $
command n SectionCommon d paramPaths (withParams seek)
seek :: CmdParams -> CommandSeek

View file

@ -16,7 +16,7 @@ import Logs.Trust
import Logs.Web
cmd :: Command
cmd = noCommit $ withOptions (jsonOption : annexedMatchingOptions ++ keyOptions) $
cmd = noCommit $ withGlobalOptions (jsonOption : annexedMatchingOptions) $
command "whereis" SectionQuery
"lists repositories that have file content"
paramPaths (withParams seek)
@ -27,8 +27,6 @@ data WhereisOptions = WhereisOptions
, keyOptions :: Maybe KeyOptions
}
-- TODO: annexedMatchingOptions
seek :: CmdParams -> CommandSeek
seek ps = do
m <- remoteMap id