summaryrefslogtreecommitdiff
path: root/Command/Add.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-10 13:18:46 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-10 13:23:06 -0400
commit19a3a331c35238a10ec2c537cf64d0b4c1fb290c (patch)
treeca5d79d0be1a80c01c9ad452331bdbebc1c4430a /Command/Add.hs
parent9886c302ef538e538ec7d48b94374b9d2400004f (diff)
finished converting all the main options
Diffstat (limited to 'Command/Add.hs')
-rw-r--r--Command/Add.hs28
1 files changed, 17 insertions, 11 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 270ac7f39..11682207e 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -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