{-# LANGUAGE NoImplicitPrelude #-}

-- | Functions to parse command line arguments for Stack's @eval@ command.

module Stack.Options.EvalParser
  ( evalOptsParser
  ) where

import           Options.Applicative ( Parser, metavar, strArgument )
import           Stack.Eval ( EvalOpts (..) )
import           Stack.Options.ExecParser ( execOptsExtraParser )
import           Stack.Prelude

-- | Parse command line arguments for Stack's @eval@ command.

evalOptsParser ::
     String -- ^ metavar

  -> Parser EvalOpts
evalOptsParser :: String -> Parser EvalOpts
evalOptsParser String
meta = String -> ExecOptsExtra -> EvalOpts
EvalOpts
  (String -> ExecOptsExtra -> EvalOpts)
-> Parser String -> Parser (ExecOptsExtra -> EvalOpts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String
eoArgsParser
  Parser (ExecOptsExtra -> EvalOpts)
-> Parser ExecOptsExtra -> Parser EvalOpts
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser ExecOptsExtra
execOptsExtraParser
 where
  eoArgsParser :: Parser String
  eoArgsParser :: Parser String
eoArgsParser = Mod ArgumentFields String -> Parser String
forall s. IsString s => Mod ArgumentFields s -> Parser s
strArgument (String -> Mod ArgumentFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
meta)