summaryrefslogtreecommitdiff
path: root/Commands.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-16 13:59:48 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-16 13:59:48 -0400
commit5f73fd5b661ecdeae164cc3d5a6c4d0b6113eba7 (patch)
treecb4570bdff48eeb103ef6a6931fc968678bf0b6e /Commands.hs
parent1260adbd7700ab9e35f61f4ad94b9cc0536f243e (diff)
dropped defaultCmd
With recusrion, it doesn't really make sense.
Diffstat (limited to 'Commands.hs')
-rw-r--r--Commands.hs23
1 files changed, 6 insertions, 17 deletions
diff --git a/Commands.hs b/Commands.hs
index f28b3e72b..3d85b12b9 100644
--- a/Commands.hs
+++ b/Commands.hs
@@ -29,18 +29,16 @@ parseCmd argv = do
(flags, params) <- getopt
case (length params) of
0 -> error header
- _ -> do
- let (cmd, locs) = takeCmd params $ lookupCmd (params !! 0)
- files <- mapM recurseFiles locs
- return (flags, map cmd $ foldl (++) [] files)
+ _ -> case (lookupCmd (params !! 0)) of
+ [] -> error header
+ [(_,cmd)] -> do
+ let locs = drop 1 params
+ files <- mapM recurseFiles locs
+ return (flags, map cmd $ foldl (++) [] files)
where
getopt = case getOpt Permute options argv of
(flags, nonopts, []) -> return (flags, nonopts)
(_, _, errs) -> ioError (userError (concat errs ++ usageInfo header options))
- takeCmd files cmds =
- if (0 == length cmds)
- then (defaultCmd, files)
- else ((snd $ cmds !! 0), drop 1 files)
lookupCmd cmd = filter (\(c, a) -> c == cmd) cmds
cmds = [ ("add", addCmd)
, ("get", getCmd)
@@ -54,15 +52,6 @@ parseCmd argv = do
(join "|" $ map fst cmds) ++ "] file ..."
options = [ Option ['f'] ["force"] (NoArg Force) "allow actions that may loose annexed data" ]
-{- Default mode is to annex a file if it is not already, and otherwise
- - get its content. -}
-defaultCmd :: FilePath -> Annex ()
-defaultCmd file = do
- r <- liftIO $ Backend.lookupFile file
- case (r) of
- Just v -> getCmd file
- Nothing -> addCmd file
-
{- Annexes a file, storing it in a backend, and then moving it into
- the annex directory and setting up the symlink pointing to its content. -}
addCmd :: FilePath -> Annex ()