Forbid "leftover" args to interactive commands
This commit is contained in:
parent
a1079f22a0
commit
d0c53ec937
@ -110,7 +110,7 @@ legacyInteractiveLoop symdbreq world = do
|
||||
res <- flip gcatches interactiveHandlers $ do
|
||||
pargs <- maybe (throw $ InvalidCommandLine $ Left cmdArg) return
|
||||
$ parseArgsInteractive cmdArg
|
||||
case fst pargs of
|
||||
case pargs of
|
||||
CmdFind symbol ->
|
||||
lookupSymbol symbol =<< checkDb symdbreq =<< getDb symdbreq
|
||||
|
||||
|
@ -37,7 +37,7 @@ parseArgs =
|
||||
$$ fullDesc
|
||||
<=> header "ghc-mod: Happy Haskell Programming"
|
||||
|
||||
parseArgsInteractive :: String -> Maybe (GhcModCommands, [String])
|
||||
parseArgsInteractive :: String -> Maybe GhcModCommands
|
||||
parseArgsInteractive args =
|
||||
getParseResult $ execParserPure (prefs idm) opts $ parseCmdLine args
|
||||
where
|
||||
|
@ -179,12 +179,10 @@ commands =
|
||||
, text "(See also: https://github.com/kazu-yamamoto/ghc-mod/issues/311)"
|
||||
]
|
||||
|
||||
interactiveCommandsSpec :: Parser (GhcModCommands, [String])
|
||||
interactiveCommandsSpec :: Parser GhcModCommands
|
||||
interactiveCommandsSpec =
|
||||
(,) <$> subparser' icmds <*> leftover
|
||||
where
|
||||
icmds =
|
||||
commands
|
||||
subparser'
|
||||
$ commands
|
||||
<> command "map-file"
|
||||
$$ info (helper <*> mapArgSpec)
|
||||
$$ progDesc "tells ghc-modi to read `file.hs` source from stdin"
|
||||
@ -201,7 +199,6 @@ interactiveCommandsSpec =
|
||||
$$ progDesc "Exit interactive mode"
|
||||
<> command ""
|
||||
$$ info (pure CmdQuit) idm
|
||||
leftover = many (strArg "")
|
||||
|
||||
strArg :: String -> Parser String
|
||||
strArg = argument str . metavar
|
||||
|
Loading…
Reference in New Issue
Block a user