{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_HADDOCK show-extensions #-}
module Yi.Keymap.Vim.Ex.Commands.Stack (parse) where
import Control.Applicative (Alternative ((<|>)))
import Data.Attoparsec.Text as P (choice, Parser)
import Data.Text (Text)
import Data.Monoid ((<>))
import Yi.Command (stackCommandE)
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 :: EventString -> Maybe ExCommand
parse = Parser ExCommand -> EventString -> Maybe ExCommand
Common.parse (Parser ExCommand -> EventString -> Maybe ExCommand)
-> Parser ExCommand -> EventString -> Maybe ExCommand
forall a b. (a -> b) -> a -> b
$ do
Text
cmd <- Parser Text
"stack" Parser Text -> Parser Text -> Parser Text
forall a b. Parser Text a -> Parser Text b -> Parser Text b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Parser Text
" " Parser Text -> Parser Text -> Parser Text
forall a b. Parser Text a -> Parser Text b -> Parser Text b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> [Parser Text] -> Parser Text
forall (f :: * -> *) a. Alternative f => [f a] -> f a
P.choice [Parser Text]
commands Parser Text -> Parser Text -> Parser Text
forall a. Parser Text a -> Parser Text a -> Parser Text a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> Parser Text
forall a. a -> Parser Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"build")
[Text]
args <- Parser [Text]
Common.commandArgs
ExCommand -> Parser ExCommand
forall a. a -> Parser Text a
forall (m :: * -> *) a. Monad m => a -> m a
return (ExCommand -> Parser ExCommand) -> ExCommand -> Parser ExCommand
forall a b. (a -> b) -> a -> b
$ ExCommand
Common.impureExCommand {
cmdShow = "stack " <> cmd
, cmdAction = YiA $ stackCommandE cmd $ CommandArguments args
}
commands :: [P.Parser Text]
commands :: [Parser Text]
commands =
[ Parser Text
"build"
, Parser Text
"install"
, Parser Text
"uninstall"
, Parser Text
"test"
, Parser Text
"bench"
, Parser Text
"haddock"
, Parser Text
"new"
, Parser Text
"templates"
, Parser Text
"init"
, Parser Text
"solver"
, Parser Text
"setup"
, Parser Text
"path"
, Parser Text
"unpack"
, Parser Text
"update"
, Parser Text
"upgrade"
, Parser Text
"upload"
, Parser Text
"sdist"
, Parser Text
"dot"
, Parser Text
"exec"
, Parser Text
"ghc"
, Parser Text
"ghci"
, Parser Text
"repl"
, Parser Text
"runghc"
, Parser Text
"runhaskell"
, Parser Text
"eval"
, Parser Text
"clean"
, Parser Text
"list-dependencies"
, Parser Text
"query"
, Parser Text
"ide"
, Parser Text
"docker"
, Parser Text
"config"
, Parser Text
"image"
, Parser Text
"hpc"
]