diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-10 18:05:37 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-10 18:05:37 -0400 |
commit | e5514e0cb0809848645814e8c1f67cd89cb16c4f (patch) | |
tree | 7041c952f9fa00fc60a40fa8e88fa1cd54818706 /CmdLine.hs | |
parent | dce9c2e0804d2c94f46dcac8c9884766bb22dcc7 (diff) |
update
Diffstat (limited to 'CmdLine.hs')
-rw-r--r-- | CmdLine.hs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/CmdLine.hs b/CmdLine.hs new file mode 100644 index 000000000..79bd55cd9 --- /dev/null +++ b/CmdLine.hs @@ -0,0 +1,41 @@ +{- git-annex command line + - + - TODO: This is very rough and stupid; I would like to use + - System.Console.CmdArgs.Implicit but it is not yet packaged in Debian. + -} + +module CmdLine where + +import System.Console.GetOpt +import Types +import Annex + +data Flag = Add FilePath | Push String | Pull String | + Want FilePath | Get (Maybe FilePath) | Drop FilePath + deriving Show + +options :: [OptDescr Flag] +options = + [ Option ['a'] ["add"] (ReqArg Add "FILE") "add file to annex" + , Option ['p'] ["push"] (ReqArg Push "REPO") "push annex to repo" + , Option ['P'] ["pull"] (ReqArg Pull "REPO") "pull annex from repo" + , Option ['w'] ["want"] (ReqArg Want "FILE") "request file contents" + , Option ['g'] ["get"] (OptArg Get "FILE") "transfer file contents" + , Option ['d'] ["drop"] (ReqArg Drop "FILE") "indicate file content not needed" + ] + +argvToFlags argv = do + case getOpt Permute options argv of + -- no options? add listed files + ([],p,[] ) -> return $ map (\f -> Add f) p + -- all options parsed, return flags + (o,[],[] ) -> return o + -- error case + (_,n,errs) -> ioError (userError (concat errs ++ usageInfo header options)) + where header = "Usage: git-annex [option] file" + +dispatch :: Flag -> [Backend] -> GitRepo -> IO () +dispatch flag backends repo = do + case (flag) of + Add f -> annexFile backends repo f + _ -> error "not implemented" |