summaryrefslogtreecommitdiff
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-12-08 14:07:49 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-12-08 14:07:49 -0400
commit2099407d8aa1b1e94f29de0d9094ccfa6e05e471 (patch)
treead1aee35f7f5556cd3784c326732e852ecf23c1d /CmdLine.hs
parent627a3014376f83d613c448da929231bb9d866435 (diff)
Add --exclude option to exclude files from processing.
Required some lifting so flags are evaled in the Annex monad before file filtering.
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs22
1 files changed, 10 insertions, 12 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index 0903cc1fb..cb164a6ab 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -9,6 +9,7 @@ module CmdLine (parseCmd) where
import System.Console.GetOpt
import Control.Monad (when)
+import Control.Monad.State (liftIO)
import qualified Annex
import Types
@@ -103,6 +104,8 @@ options = [
"specify to where to transfer content"
, Option ['f'] ["from"] (ReqArg (storestring "fromrepository") "REPOSITORY")
"specify from where to transfer content"
+ , Option ['x'] ["exclude"] (ReqArg (storestring "exclude") "GLOB")
+ "skip files matching the glob pattern"
]
where
storebool n b = Annex.flagChange n $ FlagBool b
@@ -125,22 +128,17 @@ usage = usageInfo header options ++ "\nSubcommands:\n" ++ cmddescs
indent l = " " ++ l
pad n s = replicate (n - length s) ' '
-{- Parses command line and returns two lists of actions to be
- - run in the Annex monad. The first actions configure it
- - according to command line options, while the second actions
- - handle subcommands. -}
-parseCmd :: [String] -> AnnexState -> IO ([Annex Bool], [Annex Bool])
-parseCmd argv state = do
- (flags, params) <- getopt
+{- Parses command line, stores configure flags, and returns a
+ - list of actions to be run in the Annex monad. -}
+parseCmd :: [String] -> Annex [Annex Bool]
+parseCmd argv = do
+ (flags, params) <- liftIO $ getopt
when (null params) $ error usage
case lookupCmd (head params) of
[] -> error usage
[subcommand] -> do
- actions <- prepSubCmd subcommand state (drop 1 params)
- let configactions = map (\flag -> do
- flag
- return True) flags
- return (configactions, actions)
+ _ <- sequence flags
+ prepSubCmd subcommand (drop 1 params)
_ -> error "internal error: multiple matching subcommands"
where
getopt = case getOpt Permute options argv of