summaryrefslogtreecommitdiff
path: root/Command
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
parent9886c302ef538e538ec7d48b94374b9d2400004f (diff)
finished converting all the main options
Diffstat (limited to 'Command')
-rw-r--r--Command/Add.hs28
-rw-r--r--Command/Drop.hs9
-rw-r--r--Command/Find.hs2
-rw-r--r--Command/Fix.hs2
-rw-r--r--Command/Fsck.hs9
-rw-r--r--Command/Get.hs9
-rw-r--r--Command/Import.hs2
-rw-r--r--Command/Lock.hs2
-rw-r--r--Command/Log.hs4
-rw-r--r--Command/Migrate.hs2
-rw-r--r--Command/Move.hs9
-rw-r--r--Command/Unannex.hs2
-rw-r--r--Command/Unlock.hs2
-rw-r--r--Command/Whereis.hs4
14 files changed, 43 insertions, 43 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
diff --git a/Command/Drop.hs b/Command/Drop.hs
index 7141cbc48..feb89b70e 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -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
diff --git a/Command/Find.hs b/Command/Find.hs
index eb681d219..dd82bd401 100644
--- a/Command/Find.hs
+++ b/Command/Find.hs
@@ -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)
diff --git a/Command/Fix.hs b/Command/Fix.hs
index a5f385b4f..abaedb30b 100644
--- a/Command/Fix.hs
+++ b/Command/Fix.hs
@@ -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)
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 0c5251ecb..0e0c49d78 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -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
diff --git a/Command/Get.hs b/Command/Get.hs
index 3af09b642..324ff2752 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -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)
diff --git a/Command/Import.hs b/Command/Import.hs
index 8d09f8478..684641ea3 100644
--- a/Command/Import.hs
+++ b/Command/Import.hs
@@ -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
diff --git a/Command/Lock.hs b/Command/Lock.hs
index 04c8b9494..7711ec3b8 100644
--- a/Command/Lock.hs
+++ b/Command/Lock.hs
@@ -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)
diff --git a/Command/Log.hs b/Command/Log.hs
index 6f3967c6a..eb740b249 100644
--- a/Command/Log.hs
+++ b/Command/Log.hs
@@ -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]
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index 80d42e87a..d1c7902d7 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -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)
diff --git a/Command/Move.hs b/Command/Move.hs
index 087ea0a7b..d95bce6ab 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -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
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index ea814560f..fdf976d3e 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -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)
diff --git a/Command/Unlock.hs b/Command/Unlock.hs
index 36b0023d8..d1b1d0e90 100644
--- a/Command/Unlock.hs
+++ b/Command/Unlock.hs
@@ -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
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
index fb28daa22..2c6018b24 100644
--- a/Command/Whereis.hs
+++ b/Command/Whereis.hs
@@ -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