always run autocorrect code on fuzzy matches, even if there is just 1
This commit is contained in:
parent
70538dac84
commit
42cbb41ada
1 changed files with 5 additions and 5 deletions
10
CmdLine.hs
10
CmdLine.hs
|
@ -46,19 +46,19 @@ dispatch fuzzyok allargs allcmds commonoptions header getgitrepo = do
|
||||||
where
|
where
|
||||||
err msg = msg ++ "\n\n" ++ usage header allcmds commonoptions
|
err msg = msg ++ "\n\n" ++ usage header allcmds commonoptions
|
||||||
cmd = Prelude.head cmds
|
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
|
(flags, params) = getOptCmd args cmd commonoptions err
|
||||||
checkfuzzy = when (length cmds > 1) $
|
checkfuzzy = when fuzzy $
|
||||||
inRepo $ Git.AutoCorrect.prepare name cmdname cmds
|
inRepo $ Git.AutoCorrect.prepare name cmdname cmds
|
||||||
|
|
||||||
{- Parses command line params far enough to find the Command to run, and
|
{- Parses command line params far enough to find the Command to run, and
|
||||||
- returns the remaining params.
|
- returns the remaining params.
|
||||||
- Does fuzzy matching if necessary, which may result in multiple Commands. -}
|
- 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
|
findCmd fuzzyok argv cmds err
|
||||||
| isNothing name = error $ err "missing command"
|
| isNothing name = error $ err "missing command"
|
||||||
| not (null exactcmds) = (exactcmds, fromJust name, args)
|
| not (null exactcmds) = (False, exactcmds, fromJust name, args)
|
||||||
| fuzzyok && not (null inexactcmds) = (inexactcmds, fromJust name, args)
|
| fuzzyok && not (null inexactcmds) = (True, inexactcmds, fromJust name, args)
|
||||||
| otherwise = error $ err $ "unknown command " ++ fromJust name
|
| otherwise = error $ err $ "unknown command " ++ fromJust name
|
||||||
where
|
where
|
||||||
(name, args) = findname argv []
|
(name, args) = findname argv []
|
||||||
|
|
Loading…
Reference in a new issue