diff options
author | Joey Hess <joey@kitenet.net> | 2010-12-30 15:44:15 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-12-30 15:44:15 -0400 |
commit | 88ff9e82fc3dcb653b2a116f1c162d98a1f6bdcf (patch) | |
tree | cb52cb0a0e2326e61e30b8f364d96fb6c39fa44f /CmdLine.hs | |
parent | 1c451fe3628f535898e7cf87ccad30270c6d16fb (diff) |
factor out a little more
Diffstat (limited to 'CmdLine.hs')
-rw-r--r-- | CmdLine.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/CmdLine.hs b/CmdLine.hs index a2645f75f..b3dfc984d 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -6,19 +6,25 @@ -} module CmdLine ( + cmdLine, parseCmd, Option, storeOptBool, storeOptString, ) where +import System.Environment import System.Console.GetOpt import Control.Monad (when) import Control.Monad.State (liftIO) import qualified Annex +import qualified GitRepo as Git import Types import Command +import BackendList +import Core +import Upgrade {- Each dashed command-line option results in generation of an action - in the Annex monad that performs the necessary setting. @@ -30,6 +36,15 @@ storeOptBool name val = Annex.flagChange name $ FlagBool val storeOptString :: FlagName -> String -> Annex () storeOptString name val = Annex.flagChange name $ FlagString val +{- It all starts here. -} +cmdLine :: [Command] -> [Option] -> String -> IO () +cmdLine cmds options header = do + args <- getArgs + gitrepo <- Git.repoFromCwd + state <- Annex.new gitrepo allBackends + (actions, state') <- Annex.run state $ parseCmd args header cmds options + tryRun state' $ [startup, upgrade] ++ actions + {- Parses command line, stores configure flags, and returns a - list of actions to be run in the Annex monad. -} parseCmd :: [String] -> String -> [Command] -> [Option] -> Annex [Annex Bool] |