{-# LANGUAGE NoImplicitPrelude   #-}
{-# LANGUAGE OverloadedStrings   #-}

-- | Function to parse command line arguments for Stack's @ls@ command.

module Stack.Options.LsParser
  ( lsOptsParser
  ) where

import qualified Data.Text as T
import qualified Options.Applicative as OA
import           Options.Applicative ( idm )
import           Options.Applicative.Builder.Extra ( boolFlags, textOption )
import           Stack.Constants ( globalFooter )
import           Stack.Ls
                   ( ListDepsFormat (..), ListDepsFormatOpts (..)
                   , ListDepsOpts (..), ListDepsTextFilter (..)
                   , ListStylesOpts (..), ListToolsOpts (..), LsCmdOpts (..)
                   , LsCmds (..), LsView (..), SnapshotOpts (..)
                   )
import           Stack.Options.DotParser ( dotOptsParser )
import           Stack.Prelude

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

lsOptsParser :: OA.Parser LsCmdOpts
lsOptsParser :: Parser LsCmdOpts
lsOptsParser = LsCmds -> LsCmdOpts
LsCmdOpts
  (LsCmds -> LsCmdOpts) -> Parser LsCmds -> Parser LsCmdOpts
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mod CommandFields LsCmds -> Parser LsCmds
forall a. Mod CommandFields a -> Parser a
OA.hsubparser (Mod CommandFields LsCmds
lsSnapCmd Mod CommandFields LsCmds
-> Mod CommandFields LsCmds -> Mod CommandFields LsCmds
forall a. Semigroup a => a -> a -> a
<> Mod CommandFields LsCmds
lsDepsCmd Mod CommandFields LsCmds
-> Mod CommandFields LsCmds -> Mod CommandFields LsCmds
forall a. Semigroup a => a -> a -> a
<> Mod CommandFields LsCmds
lsStylesCmd Mod CommandFields LsCmds
-> Mod CommandFields LsCmds -> Mod CommandFields LsCmds
forall a. Semigroup a => a -> a -> a
<> Mod CommandFields LsCmds
lsToolsCmd)

lsSnapCmd :: OA.Mod OA.CommandFields LsCmds
lsSnapCmd :: Mod CommandFields LsCmds
lsSnapCmd = String -> ParserInfo LsCmds -> Mod CommandFields LsCmds
forall a. String -> ParserInfo a -> Mod CommandFields a
OA.command String
"snapshots" (ParserInfo LsCmds -> Mod CommandFields LsCmds)
-> ParserInfo LsCmds -> Mod CommandFields LsCmds
forall a b. (a -> b) -> a -> b
$
  Parser LsCmds -> InfoMod LsCmds -> ParserInfo LsCmds
forall a. Parser a -> InfoMod a -> ParserInfo a
OA.info Parser LsCmds
lsCmdOptsParser (InfoMod LsCmds -> ParserInfo LsCmds)
-> InfoMod LsCmds -> ParserInfo LsCmds
forall a b. (a -> b) -> a -> b
$
       String -> InfoMod LsCmds
forall a. String -> InfoMod a
OA.progDesc String
"View snapshots. (default: local)"
    InfoMod LsCmds -> InfoMod LsCmds -> InfoMod LsCmds
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod LsCmds
forall a. String -> InfoMod a
OA.footer String
localSnapshotMsg

lsDepsCmd :: OA.Mod OA.CommandFields LsCmds
lsDepsCmd :: Mod CommandFields LsCmds
lsDepsCmd = String -> ParserInfo LsCmds -> Mod CommandFields LsCmds
forall a. String -> ParserInfo a -> Mod CommandFields a
OA.command String
"dependencies" (ParserInfo LsCmds -> Mod CommandFields LsCmds)
-> ParserInfo LsCmds -> Mod CommandFields LsCmds
forall a b. (a -> b) -> a -> b
$
  Parser LsCmds -> InfoMod LsCmds -> ParserInfo LsCmds
forall a. Parser a -> InfoMod a -> ParserInfo a
OA.info Parser LsCmds
lsDepOptsParser (InfoMod LsCmds -> ParserInfo LsCmds)
-> InfoMod LsCmds -> ParserInfo LsCmds
forall a b. (a -> b) -> a -> b
$
       String -> InfoMod LsCmds
forall a. String -> InfoMod a
OA.progDesc String
"View the dependencies."
    InfoMod LsCmds -> InfoMod LsCmds -> InfoMod LsCmds
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod LsCmds
forall a. String -> InfoMod a
OA.footer String
globalFooter

lsStylesCmd :: OA.Mod OA.CommandFields LsCmds
lsStylesCmd :: Mod CommandFields LsCmds
lsStylesCmd =
     String -> ParserInfo LsCmds -> Mod CommandFields LsCmds
forall a. String -> ParserInfo a -> Mod CommandFields a
OA.command
       String
"stack-colors"
       (Parser LsCmds -> InfoMod LsCmds -> ParserInfo LsCmds
forall a. Parser a -> InfoMod a -> ParserInfo a
OA.info Parser LsCmds
lsStylesOptsParser
                (String -> InfoMod LsCmds
forall a. String -> InfoMod a
OA.progDesc String
"View Stack's output styles."))
  Mod CommandFields LsCmds
-> Mod CommandFields LsCmds -> Mod CommandFields LsCmds
forall a. Semigroup a => a -> a -> a
<> String -> ParserInfo LsCmds -> Mod CommandFields LsCmds
forall a. String -> ParserInfo a -> Mod CommandFields a
OA.command
       String
"stack-colours"
       (Parser LsCmds -> InfoMod LsCmds -> ParserInfo LsCmds
forall a. Parser a -> InfoMod a -> ParserInfo a
OA.info Parser LsCmds
lsStylesOptsParser
                (String -> InfoMod LsCmds
forall a. String -> InfoMod a
OA.progDesc String
"View Stack's output styles (alias for \
                             \'stack-colors')."))

lsToolsCmd :: OA.Mod OA.CommandFields LsCmds
lsToolsCmd :: Mod CommandFields LsCmds
lsToolsCmd =
  String -> ParserInfo LsCmds -> Mod CommandFields LsCmds
forall a. String -> ParserInfo a -> Mod CommandFields a
OA.command
    String
"tools"
    (Parser LsCmds -> InfoMod LsCmds -> ParserInfo LsCmds
forall a. Parser a -> InfoMod a -> ParserInfo a
OA.info Parser LsCmds
lsToolsOptsParser
             (String -> InfoMod LsCmds
forall a. String -> InfoMod a
OA.progDesc String
"View Stack's installed tools."))

lsCmdOptsParser :: OA.Parser LsCmds
lsCmdOptsParser :: Parser LsCmds
lsCmdOptsParser = SnapshotOpts -> LsCmds
LsSnapshot (SnapshotOpts -> LsCmds) -> Parser SnapshotOpts -> Parser LsCmds
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser SnapshotOpts
lsViewSnapCmd

lsDepOptsParser :: OA.Parser LsCmds
lsDepOptsParser :: Parser LsCmds
lsDepOptsParser = ListDepsOpts -> LsCmds
LsDependencies (ListDepsOpts -> LsCmds) -> Parser ListDepsOpts -> Parser LsCmds
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ListDepsOpts
listDepsOptsParser

lsStylesOptsParser :: OA.Parser LsCmds
lsStylesOptsParser :: Parser LsCmds
lsStylesOptsParser = ListStylesOpts -> LsCmds
LsStyles (ListStylesOpts -> LsCmds)
-> Parser ListStylesOpts -> Parser LsCmds
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ListStylesOpts
listStylesOptsParser

lsToolsOptsParser :: OA.Parser LsCmds
lsToolsOptsParser :: Parser LsCmds
lsToolsOptsParser = ListToolsOpts -> LsCmds
LsTools (ListToolsOpts -> LsCmds) -> Parser ListToolsOpts -> Parser LsCmds
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ListToolsOpts
listToolsOptsParser

lsViewSnapCmd :: OA.Parser SnapshotOpts
lsViewSnapCmd :: Parser SnapshotOpts
lsViewSnapCmd = LsView -> Bool -> Bool -> SnapshotOpts
SnapshotOpts
  (LsView -> Bool -> Bool -> SnapshotOpts)
-> Parser LsView -> Parser (Bool -> Bool -> SnapshotOpts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ( Mod CommandFields LsView -> Parser LsView
forall a. Mod CommandFields a -> Parser a
OA.hsubparser (Mod CommandFields LsView
lsViewRemoteCmd Mod CommandFields LsView
-> Mod CommandFields LsView -> Mod CommandFields LsView
forall a. Semigroup a => a -> a -> a
<> Mod CommandFields LsView
lsViewLocalCmd) Parser LsView -> Parser LsView -> Parser LsView
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> LsView -> Parser LsView
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure LsView
Local)
  Parser (Bool -> Bool -> SnapshotOpts)
-> Parser Bool -> Parser (Bool -> SnapshotOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Mod FlagFields Bool -> Parser Bool
OA.switch
        (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
OA.long String
"lts"
        Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> Char -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => Char -> Mod f a
OA.short Char
'l'
        Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
OA.help String
"Only show LTS Haskell snapshots."
        )
  Parser (Bool -> SnapshotOpts) -> Parser Bool -> Parser SnapshotOpts
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Mod FlagFields Bool -> Parser Bool
OA.switch
        (  String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
OA.long String
"nightly"
        Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> Char -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => Char -> Mod f a
OA.short Char
'n'
        Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
OA.help String
"Only show Nightly snapshots."
        )

lsViewRemoteCmd :: OA.Mod OA.CommandFields LsView
lsViewRemoteCmd :: Mod CommandFields LsView
lsViewRemoteCmd = String -> ParserInfo LsView -> Mod CommandFields LsView
forall a. String -> ParserInfo a -> Mod CommandFields a
OA.command String
"remote" (ParserInfo LsView -> Mod CommandFields LsView)
-> ParserInfo LsView -> Mod CommandFields LsView
forall a b. (a -> b) -> a -> b
$
  Parser LsView -> InfoMod LsView -> ParserInfo LsView
forall a. Parser a -> InfoMod a -> ParserInfo a
OA.info (LsView -> Parser LsView
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure LsView
Remote) (InfoMod LsView -> ParserInfo LsView)
-> InfoMod LsView -> ParserInfo LsView
forall a b. (a -> b) -> a -> b
$
       String -> InfoMod LsView
forall a. String -> InfoMod a
OA.progDesc String
"View remote snapshots."
    InfoMod LsView -> InfoMod LsView -> InfoMod LsView
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod LsView
forall a. String -> InfoMod a
OA.footer String
pagerMsg

pagerMsg :: String
pagerMsg :: String
pagerMsg =
  String
"On a terminal, uses a pager, if one is available. Respects the PAGER \
  \environment variable (subject to that, prefers pager 'less' to 'more')."

lsViewLocalCmd :: OA.Mod OA.CommandFields LsView
lsViewLocalCmd :: Mod CommandFields LsView
lsViewLocalCmd = String -> ParserInfo LsView -> Mod CommandFields LsView
forall a. String -> ParserInfo a -> Mod CommandFields a
OA.command String
"local" (ParserInfo LsView -> Mod CommandFields LsView)
-> ParserInfo LsView -> Mod CommandFields LsView
forall a b. (a -> b) -> a -> b
$
  Parser LsView -> InfoMod LsView -> ParserInfo LsView
forall a. Parser a -> InfoMod a -> ParserInfo a
OA.info (LsView -> Parser LsView
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure LsView
Local) (InfoMod LsView -> ParserInfo LsView)
-> InfoMod LsView -> ParserInfo LsView
forall a b. (a -> b) -> a -> b
$
       String -> InfoMod LsView
forall a. String -> InfoMod a
OA.progDesc String
"View local snapshots."
    InfoMod LsView -> InfoMod LsView -> InfoMod LsView
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod LsView
forall a. String -> InfoMod a
OA.footer String
localSnapshotMsg

localSnapshotMsg :: String
localSnapshotMsg :: String
localSnapshotMsg =
  String
"A local snapshot is identified by a hash code. " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
pagerMsg

-- | Parser for arguments to `stack ls dependencies`.

listDepsOptsParser :: OA.Parser ListDepsOpts
listDepsOptsParser :: Parser ListDepsOpts
listDepsOptsParser = Mod CommandFields ListDepsOpts -> Parser ListDepsOpts
forall a. Mod CommandFields a -> Parser a
OA.subparser
      (  String
-> String
-> Parser ListDepsFormat
-> Mod CommandFields ListDepsOpts
formatSubCommand
           String
"text"
           String
"Print dependencies as text (default)."
           Parser ListDepsFormat
listDepsTextParser
      Mod CommandFields ListDepsOpts
-> Mod CommandFields ListDepsOpts -> Mod CommandFields ListDepsOpts
forall a. Semigroup a => a -> a -> a
<> String
-> String
-> Parser ListDepsFormat
-> Mod CommandFields ListDepsOpts
formatSubCommand
           String
"cabal"
           String
"Print dependencies as exact Cabal constraints."
           Parser ListDepsFormat
listDepsConstraintsParser
      Mod CommandFields ListDepsOpts
-> Mod CommandFields ListDepsOpts -> Mod CommandFields ListDepsOpts
forall a. Semigroup a => a -> a -> a
<> String
-> String
-> Parser ListDepsFormat
-> Mod CommandFields ListDepsOpts
formatSubCommand
           String
"tree"
           String
"Print dependencies as tree."
           Parser ListDepsFormat
listDepsTreeParser
      Mod CommandFields ListDepsOpts
-> Mod CommandFields ListDepsOpts -> Mod CommandFields ListDepsOpts
forall a. Semigroup a => a -> a -> a
<> String
-> String
-> Parser ListDepsFormat
-> Mod CommandFields ListDepsOpts
formatSubCommand
           String
"json"
           String
"Print dependencies as JSON."
           Parser ListDepsFormat
listDepsJsonParser
      )
  Parser ListDepsOpts -> Parser ListDepsOpts -> Parser ListDepsOpts
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser ListDepsFormat -> Parser ListDepsOpts
toListDepsOptsParser Parser ListDepsFormat
listDepsTextParser

formatSubCommand ::
     String
  -> String
  -> OA.Parser ListDepsFormat
  -> OA.Mod OA.CommandFields ListDepsOpts
formatSubCommand :: String
-> String
-> Parser ListDepsFormat
-> Mod CommandFields ListDepsOpts
formatSubCommand String
cmd String
desc Parser ListDepsFormat
formatParser =
  String -> ParserInfo ListDepsOpts -> Mod CommandFields ListDepsOpts
forall a. String -> ParserInfo a -> Mod CommandFields a
OA.command
    String
cmd
    (Parser ListDepsOpts
-> InfoMod ListDepsOpts -> ParserInfo ListDepsOpts
forall a. Parser a -> InfoMod a -> ParserInfo a
OA.info (Parser ListDepsFormat -> Parser ListDepsOpts
toListDepsOptsParser Parser ListDepsFormat
formatParser) (String -> InfoMod ListDepsOpts
forall a. String -> InfoMod a
OA.progDesc String
desc))

listDepsTextParser :: OA.Parser ListDepsFormat
listDepsTextParser :: Parser ListDepsFormat
listDepsTextParser =
  ListDepsFormatOpts -> [ListDepsTextFilter] -> ListDepsFormat
ListDepsText (ListDepsFormatOpts -> [ListDepsTextFilter] -> ListDepsFormat)
-> Parser ListDepsFormatOpts
-> Parser ([ListDepsTextFilter] -> ListDepsFormat)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ListDepsFormatOpts
listDepsFormatOptsParser Parser ([ListDepsTextFilter] -> ListDepsFormat)
-> Parser [ListDepsTextFilter] -> Parser ListDepsFormat
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser [ListDepsTextFilter]
textFilterParser

textFilterParser :: OA.Parser [ListDepsTextFilter]
textFilterParser :: Parser [ListDepsTextFilter]
textFilterParser = Parser ListDepsTextFilter -> Parser [ListDepsTextFilter]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (ReadM ListDepsTextFilter
-> Mod OptionFields ListDepsTextFilter -> Parser ListDepsTextFilter
forall a. ReadM a -> Mod OptionFields a -> Parser a
OA.option ReadM ListDepsTextFilter
parseListDepsTextFilter
  (  String -> Mod OptionFields ListDepsTextFilter
forall (f :: * -> *) a. HasName f => String -> Mod f a
OA.long String
"filter"
  Mod OptionFields ListDepsTextFilter
-> Mod OptionFields ListDepsTextFilter
-> Mod OptionFields ListDepsTextFilter
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields ListDepsTextFilter
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
OA.metavar String
"ITEM"
  Mod OptionFields ListDepsTextFilter
-> Mod OptionFields ListDepsTextFilter
-> Mod OptionFields ListDepsTextFilter
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields ListDepsTextFilter
forall (f :: * -> *) a. String -> Mod f a
OA.help String
"Item to be filtered out of the results, if present, being either \
             \$locals (for all local packages) or a package name (can be \
             \specified multiple times)."
  ))

parseListDepsTextFilter :: OA.ReadM ListDepsTextFilter
parseListDepsTextFilter :: ReadM ListDepsTextFilter
parseListDepsTextFilter = (String -> Either String ListDepsTextFilter)
-> ReadM ListDepsTextFilter
forall a. (String -> Either String a) -> ReadM a
OA.eitherReader ((String -> Either String ListDepsTextFilter)
 -> ReadM ListDepsTextFilter)
-> (String -> Either String ListDepsTextFilter)
-> ReadM ListDepsTextFilter
forall a b. (a -> b) -> a -> b
$ \String
s ->
  if String
s String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"$locals"
    then ListDepsTextFilter -> Either String ListDepsTextFilter
forall a b. b -> Either a b
Right ListDepsTextFilter
FilterLocals
    else case String -> Maybe PackageName
parsePackageName String
s of
      Just PackageName
pkgName -> ListDepsTextFilter -> Either String ListDepsTextFilter
forall a b. b -> Either a b
Right (ListDepsTextFilter -> Either String ListDepsTextFilter)
-> ListDepsTextFilter -> Either String ListDepsTextFilter
forall a b. (a -> b) -> a -> b
$ PackageName -> ListDepsTextFilter
FilterPackage PackageName
pkgName
      Maybe PackageName
Nothing -> String -> Either String ListDepsTextFilter
forall a b. a -> Either a b
Left (String -> Either String ListDepsTextFilter)
-> String -> Either String ListDepsTextFilter
forall a b. (a -> b) -> a -> b
$ String
s String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" is not a valid package name."

listDepsConstraintsParser :: OA.Parser ListDepsFormat
listDepsConstraintsParser :: Parser ListDepsFormat
listDepsConstraintsParser = ListDepsFormat -> Parser ListDepsFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ListDepsFormat
ListDepsConstraints

listDepsTreeParser :: OA.Parser ListDepsFormat
listDepsTreeParser :: Parser ListDepsFormat
listDepsTreeParser =  ListDepsFormatOpts -> ListDepsFormat
ListDepsTree (ListDepsFormatOpts -> ListDepsFormat)
-> Parser ListDepsFormatOpts -> Parser ListDepsFormat
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ListDepsFormatOpts
listDepsFormatOptsParser

listDepsJsonParser :: OA.Parser ListDepsFormat
listDepsJsonParser :: Parser ListDepsFormat
listDepsJsonParser = ListDepsFormat -> Parser ListDepsFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ListDepsFormat
ListDepsJSON

listDepsFormatOptsParser :: OA.Parser ListDepsFormatOpts
listDepsFormatOptsParser :: Parser ListDepsFormatOpts
listDepsFormatOptsParser = Text -> Bool -> ListDepsFormatOpts
ListDepsFormatOpts
  (Text -> Bool -> ListDepsFormatOpts)
-> Parser Text -> Parser (Bool -> ListDepsFormatOpts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Text
separatorParser
  Parser (Bool -> ListDepsFormatOpts)
-> Parser Bool -> Parser ListDepsFormatOpts
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Bool
licenseParser

separatorParser :: OA.Parser Text
separatorParser :: Parser Text
separatorParser = (Text -> Text) -> Parser Text -> Parser Text
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
  Text -> Text
escapeSep
  ( Mod OptionFields Text -> Parser Text
textOption
      (  String -> Mod OptionFields Text
forall (f :: * -> *) a. HasName f => String -> Mod f a
OA.long String
"separator"
      Mod OptionFields Text
-> Mod OptionFields Text -> Mod OptionFields Text
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Text
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
OA.metavar String
"SEP"
      Mod OptionFields Text
-> Mod OptionFields Text -> Mod OptionFields Text
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Text
forall (f :: * -> *) a. String -> Mod f a
OA.help String
"Separator between package name and package version."
      Mod OptionFields Text
-> Mod OptionFields Text -> Mod OptionFields Text
forall a. Semigroup a => a -> a -> a
<> Text -> Mod OptionFields Text
forall (f :: * -> *) a. HasValue f => a -> Mod f a
OA.value Text
" "
      Mod OptionFields Text
-> Mod OptionFields Text -> Mod OptionFields Text
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields Text
forall a (f :: * -> *). Show a => Mod f a
OA.showDefault
      )
  )
 where
  escapeSep :: Text -> Text
escapeSep Text
s = HasCallStack => Text -> Text -> Text -> Text
Text -> Text -> Text -> Text
T.replace Text
"\\t" Text
"\t" (HasCallStack => Text -> Text -> Text -> Text
Text -> Text -> Text -> Text
T.replace Text
"\\n" Text
"\n" Text
s)

licenseParser :: OA.Parser Bool
licenseParser :: Parser Bool
licenseParser = Bool -> String -> String -> Mod FlagFields Bool -> Parser Bool
boolFlags Bool
False
  String
"license"
  String
"printing of dependency licenses instead of versions."
  Mod FlagFields Bool
forall m. Monoid m => m
idm

toListDepsOptsParser :: OA.Parser ListDepsFormat -> OA.Parser ListDepsOpts
toListDepsOptsParser :: Parser ListDepsFormat -> Parser ListDepsOpts
toListDepsOptsParser Parser ListDepsFormat
formatParser = ListDepsFormat -> DotOpts -> ListDepsOpts
ListDepsOpts
  (ListDepsFormat -> DotOpts -> ListDepsOpts)
-> Parser ListDepsFormat -> Parser (DotOpts -> ListDepsOpts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ListDepsFormat
formatParser
  Parser (DotOpts -> ListDepsOpts)
-> Parser DotOpts -> Parser ListDepsOpts
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Parser DotOpts
dotOptsParser Bool
True

listStylesOptsParser :: OA.Parser ListStylesOpts
listStylesOptsParser :: Parser ListStylesOpts
listStylesOptsParser = Bool -> Bool -> Bool -> ListStylesOpts
ListStylesOpts
  (Bool -> Bool -> Bool -> ListStylesOpts)
-> Parser Bool -> Parser (Bool -> Bool -> ListStylesOpts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> String -> String -> Mod FlagFields Bool -> Parser Bool
boolFlags Bool
False
        String
"basic"
        String
"a basic report of the styles used. The default is a fuller one."
        Mod FlagFields Bool
forall m. Monoid m => m
idm
  Parser (Bool -> Bool -> ListStylesOpts)
-> Parser Bool -> Parser (Bool -> ListStylesOpts)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> String -> String -> Mod FlagFields Bool -> Parser Bool
boolFlags Bool
True
        String
"sgr"
        String
"the provision of the equivalent SGR instructions (provided by \
        \default). Flag ignored for a basic report."
        Mod FlagFields Bool
forall m. Monoid m => m
idm
  Parser (Bool -> ListStylesOpts)
-> Parser Bool -> Parser ListStylesOpts
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> String -> String -> Mod FlagFields Bool -> Parser Bool
boolFlags Bool
True
        String
"example"
        String
"the provision of an example of the applied style (provided by default \
        \for colored output). Flag ignored for a basic report."
        Mod FlagFields Bool
forall m. Monoid m => m
idm

listToolsOptsParser :: OA.Parser ListToolsOpts
listToolsOptsParser :: Parser ListToolsOpts
listToolsOptsParser = String -> ListToolsOpts
ListToolsOpts
  (String -> ListToolsOpts) -> Parser String -> Parser ListToolsOpts
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
OA.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
OA.long String
"filter"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
OA.metavar String
"TOOL_NAME"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasValue f => a -> Mod f a
OA.value String
""
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
OA.help String
"Filter by a tool name (eg 'ghc', 'ghc-git' or 'msys2') \
                   \- case sensitive. (default: no filter)"
        )