diff options
author | Joey Hess <joey@kitenet.net> | 2012-04-14 16:01:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-04-14 16:01:39 -0400 |
commit | 42cbb41ada884b21d7bbd369003b71752260c44e (patch) | |
tree | ce66f14b92a5e566c8f7f1514e59c1326161204e | |
parent | 70538dac844f00ccbdd0f2d0283fbf4e707cb84a (diff) |
always run autocorrect code on fuzzy matches, even if there is just 1
-rw-r--r-- | CmdLine.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/CmdLine.hs b/CmdLine.hs index 5330f40fc..ebaef5369 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -46,19 +46,19 @@ dispatch fuzzyok allargs allcmds commonoptions header getgitrepo = do where err msg = msg ++ "\n\n" ++ usage header allcmds commonoptions cmd = Prelude.head cmds - (cmds, name, args) = findCmd fuzzyok allargs allcmds err + (fuzzy, cmds, name, args) = findCmd fuzzyok allargs allcmds err (flags, params) = getOptCmd args cmd commonoptions err - checkfuzzy = when (length cmds > 1) $ + checkfuzzy = when fuzzy $ inRepo $ Git.AutoCorrect.prepare name cmdname cmds {- 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) -> ([Command], String, Params) +findCmd :: Bool -> Params -> [Command] -> (String -> String) -> (Bool, [Command], String, Params) findCmd fuzzyok argv cmds err | isNothing name = error $ err "missing command" - | not (null exactcmds) = (exactcmds, fromJust name, args) - | fuzzyok && not (null inexactcmds) = (inexactcmds, fromJust name, args) + | not (null exactcmds) = (False, exactcmds, fromJust name, args) + | fuzzyok && not (null inexactcmds) = (True, inexactcmds, fromJust name, args) | otherwise = error $ err $ "unknown command " ++ fromJust name where (name, args) = findname argv [] |