summaryrefslogtreecommitdiff
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-30 15:18:40 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-30 15:18:40 -0400
commit440f3b1068a1d0a49dff1307124c4f7f0bcd6f5d (patch)
treedcc4b0c54f52b89aa95956c0e32cf6e781f17057 /CmdLine.hs
parentf04b34c4584e18f4c722700eda5e80eb0345f035 (diff)
make "git annex help options" work outside a git repo
Option parsing for commands that run outside git repos is still screwy, as there is no Annex monad and so the flags cannot be passed in. But, any remaining parameters can be, which is enough for this fix.
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs11
1 files changed, 4 insertions, 7 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index 83a89ef7d..7c28ecec8 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -32,16 +32,13 @@ import Annex.Environment
import Command
import Types.Messages
-type Params = [String]
-type Flags = [Annex ()]
-
{- Runs the passed command line. -}
-dispatch :: Bool -> Params -> [Command] -> [Option] -> [(String, String)] -> String -> IO Git.Repo -> IO ()
+dispatch :: Bool -> CmdParams -> [Command] -> [Option] -> [(String, String)] -> String -> IO Git.Repo -> IO ()
dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do
setupConsole
r <- E.try getgitrepo :: IO (Either E.SomeException Git.Repo)
case r of
- Left e -> fromMaybe (throw e) (cmdnorepo cmd)
+ Left e -> maybe (throw e) (\a -> a params) (cmdnorepo cmd)
Right g -> do
state <- Annex.new g
(actions, state') <- Annex.run state $ do
@@ -66,7 +63,7 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do
{- Parses command line params far enough to find the Command to run, and
- returns the remaining params.
- Does fuzzy matching if necessary, which may result in multiple Commands. -}
-findCmd :: Bool -> Params -> [Command] -> (String -> String) -> (Bool, [Command], String, Params)
+findCmd :: Bool -> CmdParams -> [Command] -> (String -> String) -> (Bool, [Command], String, CmdParams)
findCmd fuzzyok argv cmds err
| isNothing name = error $ err "missing command"
| not (null exactcmds) = (False, exactcmds, fromJust name, args)
@@ -85,7 +82,7 @@ findCmd fuzzyok argv cmds err
{- Parses command line options, and returns actions to run to configure flags
- and the remaining parameters for the command. -}
-getOptCmd :: Params -> Command -> [Option] -> (Flags, Params)
+getOptCmd :: CmdParams -> Command -> [Option] -> ([Annex ()], CmdParams)
getOptCmd argv cmd commonoptions = check $
getOpt Permute (commonoptions ++ cmdoptions cmd) argv
where