summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CmdLine.hs5
-rw-r--r--Command.hs13
-rw-r--r--Command/Add.hs2
-rw-r--r--Command/ConfigList.hs2
-rw-r--r--Command/Copy.hs2
-rw-r--r--Command/Describe.hs2
-rw-r--r--Command/Drop.hs2
-rw-r--r--Command/DropKey.hs2
-rw-r--r--Command/DropUnused.hs2
-rw-r--r--Command/Find.hs2
-rw-r--r--Command/Fix.hs2
-rw-r--r--Command/FromKey.hs2
-rw-r--r--Command/Fsck.hs2
-rw-r--r--Command/Get.hs2
-rw-r--r--Command/InAnnex.hs2
-rw-r--r--Command/Init.hs2
-rw-r--r--Command/Lock.hs2
-rw-r--r--Command/Map.hs2
-rw-r--r--Command/Migrate.hs2
-rw-r--r--Command/Move.hs2
-rw-r--r--Command/PreCommit.hs2
-rw-r--r--Command/RecvKey.hs2
-rw-r--r--Command/Semitrust.hs2
-rw-r--r--Command/SendKey.hs2
-rw-r--r--Command/SetKey.hs2
-rw-r--r--Command/Trust.hs2
-rw-r--r--Command/Unannex.hs2
-rw-r--r--Command/Uninit.hs2
-rw-r--r--Command/Unlock.hs4
-rw-r--r--Command/Untrust.hs2
-rw-r--r--Command/Unused.hs3
-rw-r--r--Command/Version.hs2
-rw-r--r--Command/Whereis.hs2
33 files changed, 46 insertions, 37 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index 6b4fd0f36..de03d96ed 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -45,7 +45,9 @@ parseCmd argv header cmds options = do
[] -> error $ "unknown command" ++ usagemsg
[command] -> do
_ <- sequence flags
- prepCmd command (drop 1 params)
+ when (cmdusesrepo command) $
+ checkVersion
+ prepCommand command (drop 1 params)
_ -> error "internal error: multiple matching commands"
where
getopt = case getOpt Permute options argv of
@@ -93,7 +95,6 @@ tryRun' _ errnum [] = do
startup :: Annex Bool
startup = do
prepUUID
- checkVersion
return True
{- Cleanup actions. -}
diff --git a/Command.hs b/Command.hs
index 41ad884a9..1449d7eed 100644
--- a/Command.hs
+++ b/Command.hs
@@ -61,13 +61,20 @@ data Command = Command {
cmdname :: String,
cmdparams :: String,
cmdseek :: [CommandSeek],
- cmddesc :: String
+ cmddesc :: String,
+ cmdusesrepo :: Bool
}
+repoCommand :: String -> String -> [CommandSeek] -> String -> Command
+repoCommand n p s d = Command n p s d True
+
+standaloneCommand :: String -> String -> [CommandSeek] -> String -> Command
+standaloneCommand n p s d = Command n p s d False
+
{- Prepares a list of actions to run to perform a command, based on
- the parameters passed to it. -}
-prepCmd :: Command -> [String] -> Annex [Annex Bool]
-prepCmd Command { cmdseek = seek } params = do
+prepCommand :: Command -> [String] -> Annex [Annex Bool]
+prepCommand Command { cmdseek = seek } params = do
lists <- mapM (\s -> s params) seek
return $ map doCommand $ concat lists
diff --git a/Command/Add.hs b/Command/Add.hs
index a577203bf..f6ccf0fb8 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -21,7 +21,7 @@ import Utility
import Touch
command :: [Command]
-command = [Command "add" paramPath seek "add files to annex"]
+command = [repoCommand "add" paramPath seek "add files to annex"]
{- Add acts on both files not checked into git yet, and unlocked files. -}
seek :: [CommandSeek]
diff --git a/Command/ConfigList.hs b/Command/ConfigList.hs
index b91c2a916..476d73cfb 100644
--- a/Command/ConfigList.hs
+++ b/Command/ConfigList.hs
@@ -14,7 +14,7 @@ import Command
import UUID
command :: [Command]
-command = [Command "configlist" paramNothing seek
+command = [standaloneCommand "configlist" paramNothing seek
"outputs relevant git configuration"]
seek :: [CommandSeek]
diff --git a/Command/Copy.hs b/Command/Copy.hs
index 93342e11b..46d49dd05 100644
--- a/Command/Copy.hs
+++ b/Command/Copy.hs
@@ -11,7 +11,7 @@ import Command
import qualified Command.Move
command :: [Command]
-command = [Command "copy" paramPath seek
+command = [repoCommand "copy" paramPath seek
"copy content of files to/from another repository"]
-- A copy is just a move that does not delete the source file.
diff --git a/Command/Describe.hs b/Command/Describe.hs
index 643ca0471..32aef4f24 100644
--- a/Command/Describe.hs
+++ b/Command/Describe.hs
@@ -16,7 +16,7 @@ import Messages
import qualified Command.Init
command :: [Command]
-command = [Command "describe" (paramPair paramRemote paramDesc) seek
+command = [repoCommand "describe" (paramPair paramRemote paramDesc) seek
"change description of a repository"]
seek :: [CommandSeek]
diff --git a/Command/Drop.hs b/Command/Drop.hs
index fdc55969f..52b724e62 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -18,7 +18,7 @@ import Messages
import Utility
command :: [Command]
-command = [Command "drop" paramPath seek
+command = [repoCommand "drop" paramPath seek
"indicate content of files not currently wanted"]
seek :: [CommandSeek]
diff --git a/Command/DropKey.hs b/Command/DropKey.hs
index b3cc60961..4c6f1ab2e 100644
--- a/Command/DropKey.hs
+++ b/Command/DropKey.hs
@@ -15,7 +15,7 @@ import Content
import Messages
command :: [Command]
-command = [Command "dropkey" (paramRepeating paramKey) seek
+command = [repoCommand "dropkey" (paramRepeating paramKey) seek
"drops annexed content for specified keys"]
seek :: [CommandSeek]
diff --git a/Command/DropUnused.hs b/Command/DropUnused.hs
index 8ed61ba65..c6a28663e 100644
--- a/Command/DropUnused.hs
+++ b/Command/DropUnused.hs
@@ -23,7 +23,7 @@ import Backend
import Key
command :: [Command]
-command = [Command "dropunused" (paramRepeating paramNumber) seek
+command = [repoCommand "dropunused" (paramRepeating paramNumber) seek
"drop unused file content"]
seek :: [CommandSeek]
diff --git a/Command/Find.hs b/Command/Find.hs
index 3ed15c153..6a6ae2978 100644
--- a/Command/Find.hs
+++ b/Command/Find.hs
@@ -14,7 +14,7 @@ import Command
import Content
command :: [Command]
-command = [Command "find" (paramOptional $ paramRepeating paramPath) seek
+command = [repoCommand "find" (paramOptional $ paramRepeating paramPath) seek
"lists available files"]
seek :: [CommandSeek]
diff --git a/Command/Fix.hs b/Command/Fix.hs
index 004754871..513e07a31 100644
--- a/Command/Fix.hs
+++ b/Command/Fix.hs
@@ -18,7 +18,7 @@ import Content
import Messages
command :: [Command]
-command = [Command "fix" paramPath seek
+command = [repoCommand "fix" paramPath seek
"fix up symlinks to point to annexed content"]
seek :: [CommandSeek]
diff --git a/Command/FromKey.hs b/Command/FromKey.hs
index 176d2cd54..8c1a1028f 100644
--- a/Command/FromKey.hs
+++ b/Command/FromKey.hs
@@ -21,7 +21,7 @@ import Messages
import Key
command :: [Command]
-command = [Command "fromkey" paramPath seek
+command = [repoCommand "fromkey" paramPath seek
"adds a file using a specific key"]
seek :: [CommandSeek]
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 76d0e38b4..216c87493 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -20,7 +20,7 @@ import Content
import LocationLog
command :: [Command]
-command = [Command "fsck" (paramOptional $ paramRepeating paramPath) seek
+command = [repoCommand "fsck" (paramOptional $ paramRepeating paramPath) seek
"check for problems"]
seek :: [CommandSeek]
diff --git a/Command/Get.hs b/Command/Get.hs
index 2aa3c0c15..0463dccb0 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -14,7 +14,7 @@ import Content
import Messages
command :: [Command]
-command = [Command "get" paramPath seek
+command = [repoCommand "get" paramPath seek
"make content of annexed files available"]
seek :: [CommandSeek]
diff --git a/Command/InAnnex.hs b/Command/InAnnex.hs
index fa81fc9a4..a7e2ecff6 100644
--- a/Command/InAnnex.hs
+++ b/Command/InAnnex.hs
@@ -14,7 +14,7 @@ import Command
import Content
command :: [Command]
-command = [Command "inannex" (paramRepeating paramKey) seek
+command = [repoCommand "inannex" (paramRepeating paramKey) seek
"checks if keys are present in the annex"]
seek :: [CommandSeek]
diff --git a/Command/Init.hs b/Command/Init.hs
index d9ea394a3..cca2e8fae 100644
--- a/Command/Init.hs
+++ b/Command/Init.hs
@@ -23,7 +23,7 @@ import Types
import Utility
command :: [Command]
-command = [Command "init" paramDesc seek
+command = [repoCommand "init" paramDesc seek
"initialize git-annex with repository description"]
seek :: [CommandSeek]
diff --git a/Command/Lock.hs b/Command/Lock.hs
index a3a39a907..cdbc56019 100644
--- a/Command/Lock.hs
+++ b/Command/Lock.hs
@@ -17,7 +17,7 @@ import qualified GitRepo as Git
import Utility
command :: [Command]
-command = [Command "lock" paramPath seek "undo unlock command"]
+command = [repoCommand "lock" paramPath seek "undo unlock command"]
seek :: [CommandSeek]
seek = [withFilesUnlocked start]
diff --git a/Command/Map.hs b/Command/Map.hs
index 6c3e0b3df..4ae947b15 100644
--- a/Command/Map.hs
+++ b/Command/Map.hs
@@ -29,7 +29,7 @@ import qualified Dot
data Link = Link Git.Repo Git.Repo
command :: [Command]
-command = [Command "map" paramNothing seek "generate map of repositories"]
+command = [repoCommand "map" paramNothing seek "generate map of repositories"]
seek :: [CommandSeek]
seek = [withNothing start]
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index c0e80c5b4..584f6e34e 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -21,7 +21,7 @@ import Messages
import qualified Command.Add
command :: [Command]
-command = [Command "migrate" paramPath seek "switch data to different backend"]
+command = [repoCommand "migrate" paramPath seek "switch data to different backend"]
seek :: [CommandSeek]
seek = [withBackendFilesInGit start]
diff --git a/Command/Move.hs b/Command/Move.hs
index 2d6c973fe..8056e95db 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -22,7 +22,7 @@ import Messages
import Utility
command :: [Command]
-command = [Command "move" paramPath seek
+command = [repoCommand "move" paramPath seek
"move content of files to/from another repository"]
seek :: [CommandSeek]
diff --git a/Command/PreCommit.hs b/Command/PreCommit.hs
index 1465ebc61..727a63728 100644
--- a/Command/PreCommit.hs
+++ b/Command/PreCommit.hs
@@ -17,7 +17,7 @@ import qualified Command.Fix
import Utility
command :: [Command]
-command = [Command "pre-commit" paramPath seek "run by git pre-commit hook"]
+command = [repoCommand "pre-commit" paramPath seek "run by git pre-commit hook"]
{- The pre-commit hook needs to fix symlinks to all files being committed.
- And, it needs to inject unlocked files into the annex. -}
diff --git a/Command/RecvKey.hs b/Command/RecvKey.hs
index c7c37d1e3..126608f61 100644
--- a/Command/RecvKey.hs
+++ b/Command/RecvKey.hs
@@ -17,7 +17,7 @@ import Content
import RsyncFile
command :: [Command]
-command = [Command "recvkey" paramKey seek
+command = [repoCommand "recvkey" paramKey seek
"runs rsync in server mode to receive content"]
seek :: [CommandSeek]
diff --git a/Command/Semitrust.hs b/Command/Semitrust.hs
index 13c6847e1..351336b89 100644
--- a/Command/Semitrust.hs
+++ b/Command/Semitrust.hs
@@ -15,7 +15,7 @@ import Trust
import Messages
command :: [Command]
-command = [Command "semitrust" (paramRepeating paramRemote) seek
+command = [repoCommand "semitrust" (paramRepeating paramRemote) seek
"return repository to default trust level"]
seek :: [CommandSeek]
diff --git a/Command/SendKey.hs b/Command/SendKey.hs
index 56974bda9..871a530af 100644
--- a/Command/SendKey.hs
+++ b/Command/SendKey.hs
@@ -18,7 +18,7 @@ import Content
import RsyncFile
command :: [Command]
-command = [Command "sendkey" paramKey seek
+command = [repoCommand "sendkey" paramKey seek
"runs rsync in server mode to send content"]
seek :: [CommandSeek]
diff --git a/Command/SetKey.hs b/Command/SetKey.hs
index fdda1c3be..af46fe06e 100644
--- a/Command/SetKey.hs
+++ b/Command/SetKey.hs
@@ -16,7 +16,7 @@ import Content
import Messages
command :: [Command]
-command = [Command "setkey" (paramRepeating paramKey) seek
+command = [repoCommand "setkey" (paramRepeating paramKey) seek
"sets annexed content for a key using a temp file"]
seek :: [CommandSeek]
diff --git a/Command/Trust.hs b/Command/Trust.hs
index ea661da2a..f7dba5648 100644
--- a/Command/Trust.hs
+++ b/Command/Trust.hs
@@ -15,7 +15,7 @@ import UUID
import Messages
command :: [Command]
-command = [Command "trust" (paramRepeating paramRemote) seek
+command = [repoCommand "trust" (paramRepeating paramRemote) seek
"trust a repository"]
seek :: [CommandSeek]
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index 42dc1fb0a..b0ce31cee 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -22,7 +22,7 @@ import qualified GitRepo as Git
import Messages
command :: [Command]
-command = [Command "unannex" paramPath seek "undo accidential add command"]
+command = [repoCommand "unannex" paramPath seek "undo accidential add command"]
seek :: [CommandSeek]
seek = [withFilesInGit start]
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index e8ac1bbd5..ee0cbde6b 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -21,7 +21,7 @@ import qualified Command.Unannex
import qualified Command.Init
command :: [Command]
-command = [Command "uninit" paramPath seek
+command = [repoCommand "uninit" paramPath seek
"de-initialize git-annex and clean out repository"]
seek :: [CommandSeek]
diff --git a/Command/Unlock.hs b/Command/Unlock.hs
index bd1021cc3..ac7b22ac7 100644
--- a/Command/Unlock.hs
+++ b/Command/Unlock.hs
@@ -22,8 +22,8 @@ import CopyFile
command :: [Command]
command =
- [ Command "unlock" paramPath seek "unlock files for modification"
- , Command "edit" paramPath seek "same as unlock"
+ [ repoCommand "unlock" paramPath seek "unlock files for modification"
+ , repoCommand "edit" paramPath seek "same as unlock"
]
seek :: [CommandSeek]
diff --git a/Command/Untrust.hs b/Command/Untrust.hs
index fdf9a83de..9c11efe46 100644
--- a/Command/Untrust.hs
+++ b/Command/Untrust.hs
@@ -15,7 +15,7 @@ import Trust
import Messages
command :: [Command]
-command = [Command "untrust" (paramRepeating paramRemote) seek
+command = [repoCommand "untrust" (paramRepeating paramRemote) seek
"do not trust a repository"]
seek :: [CommandSeek]
diff --git a/Command/Unused.hs b/Command/Unused.hs
index 52e483d87..a1c4ee03c 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -25,7 +25,8 @@ import qualified GitRepo as Git
import qualified Backend
command :: [Command]
-command = [Command "unused" paramNothing seek "look for unused file content"]
+command = [repoCommand "unused" paramNothing seek
+ "look for unused file content"]
seek :: [CommandSeek]
seek = [withNothing start]
diff --git a/Command/Version.hs b/Command/Version.hs
index ac8fdd48c..2b294c80b 100644
--- a/Command/Version.hs
+++ b/Command/Version.hs
@@ -15,7 +15,7 @@ import qualified SysConfig
import Version
command :: [Command]
-command = [Command "version" paramNothing seek "show versions"]
+command = [standaloneCommand "version" paramNothing seek "show version info"]
seek :: [CommandSeek]
seek = [withNothing start]
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
index 5b0bcbbd2..599df4467 100644
--- a/Command/Whereis.hs
+++ b/Command/Whereis.hs
@@ -17,7 +17,7 @@ import UUID
import Types
command :: [Command]
-command = [Command "whereis" (paramOptional $ paramRepeating paramPath) seek
+command = [repoCommand "whereis" (paramOptional $ paramRepeating paramPath) seek
"lists repositories that have file content"]
seek :: [CommandSeek]