module Yi.Keymap.Vim.Ex.Commands.Cabal (parse) where
import Control.Applicative (Alternative ((<|>)))
import Control.Monad (void)
import qualified Data.Text as T (pack)
import qualified Text.ParserCombinators.Parsec as P (string, try)
import Yi.Command (cabalBuildE)
import Yi.Keymap (Action (YiA))
import Yi.Keymap.Vim.Common (EventString)
import qualified Yi.Keymap.Vim.Ex.Commands.Common as Common (commandArgs, impureExCommand, parse)
import Yi.Keymap.Vim.Ex.Types (ExCommand (cmdAction, cmdShow))
import Yi.MiniBuffer (CommandArguments (CommandArguments))
parse :: EventString -> Maybe ExCommand
parse = Common.parse $ do
void $ P.try (P.string "cabal build") <|> P.try (P.string "cabal")
args <- Common.commandArgs
return $ Common.impureExCommand {
cmdShow = T.pack "cabal build"
, cmdAction = YiA $ cabalBuildE $ CommandArguments args
}