-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell CLI framework -- -- Haskell CLI framework. See README.md for more details. @package iris @version 0.1.0.0 -- | Implements a function that opens a given file in a browser. module Iris.Browse -- | Open a given file in a browser. The function has the following -- algorithm: -- --
-- handleInteractiveMode requestedInteractiveMode ---- -- If the terminal is non interactive i.e. the program is run in a pipe, -- interactive mode is set to false no matter what handleInteractiveMode :: InteractiveMode -> IO InteractiveMode instance GHC.Classes.Eq Iris.Cli.Interactive.InteractiveMode instance GHC.Show.Show Iris.Cli.Interactive.InteractiveMode -- | Wrapper around the user-defined command. -- -- ⚠️ This module is internal and doesn't follow PVP. module Iris.Cli.Internal -- | Wrapper around cmd with additional predefined fields data Cmd (cmd :: Type) Cmd :: InteractiveMode -> ColourOption -> cmd -> Cmd (cmd :: Type) [cmdInteractiveMode] :: Cmd (cmd :: Type) -> InteractiveMode [cmdColourOption] :: Cmd (cmd :: Type) -> ColourOption [cmdCmd] :: Cmd (cmd :: Type) -> cmd -- | CLI options parsing for --version and -- --numeric-version -- -- Enabled with config module Iris.Cli.Version data VersionSettings VersionSettings :: Version -> (String -> String) -> VersionSettings [versionSettingsVersion] :: VersionSettings -> Version [versionSettingsMkDesc] :: VersionSettings -> String -> String defaultVersionSettings :: Version -> VersionSettings fullVersionP :: VersionSettings -> Parser (a -> a) mkVersionParser :: Maybe VersionSettings -> Parser (a -> a) -- | The ColourMode data type that allows disabling and enabling of -- colouring. module Iris.Colour.Mode -- | Data type that tells whether the colouring is enabled or disabled. Its -- value is detected automatically on application start and stored in -- CliEnv. data ColourMode DisableColour :: ColourMode EnableColour :: ColourMode -- | This function performs a full check of the Handle colouring -- support, env variables and user-specified settings to detect whether -- the given handle supports colouring. -- -- Per CLI Guidelines, the algorithm for detecting the colouring support -- is the following: -- -- __Disable color if your program is not in a terminal or the user -- requested it. These things should disable colors:__ -- --
-- handleColourMode stdout --handleColourMode :: Handle -> IO ColourMode instance GHC.Enum.Bounded Iris.Colour.Mode.ColourMode instance GHC.Enum.Enum Iris.Colour.Mode.ColourMode instance GHC.Classes.Ord Iris.Colour.Mode.ColourMode instance GHC.Classes.Eq Iris.Colour.Mode.ColourMode instance GHC.Show.Show Iris.Colour.Mode.ColourMode -- | Settings of a CLI app environment. -- -- You're encouraged to create a separate module MyApp.Settings -- and put settings for your custom application there following the below -- pattern: -- --
-- module MyApp.Settings (appSettings) where
--
-- -- data data for your CLI arguments and CLI parser
-- import MyApp.Cli (Options, optionsP)
--
-- -- custom application environment
-- import MyApp.Env (Env)
--
-- import qualified Iris
-- import qualified Paths_myapp as Autogen
--
--
-- appSettings :: Env -> Iris.CliEnvSettings Options Env
-- appSettings env = Iris.defaultCliEnvSettings
-- { -- CLI parser for Options
-- Iris.cliEnvSettingsCmdParser = optionsP
--
-- -- Custom app environment
-- , Iris.cliEnvSettingsAppEnv = env
--
-- -- Application name
-- , Iris.cliEnvSettingsAppName =
-- Just "myapp"
--
-- -- Short app description
-- , Iris.cliEnvSettingsHeaderDesc =
-- "myapp - short description"
--
-- -- Long app description to appear in --help
-- , Iris.cliEnvSettingsProgDesc =
-- "A tool for ..."
--
-- -- How to print app version with the --version flag
-- , Iris.cliEnvSettingsVersionSettings =
-- Just (Iris.defaultVersionSettings Autogen.version)
-- { Iris.versionSettingsMkDesc = v -> "MyApp v" <> v
-- }
-- }
--
module Iris.Settings
-- | The Iris settings type.
--
-- Use defaultCliEnvSettings to specify only used fields.
data CliEnvSettings (cmd :: Type) (appEnv :: Type)
CliEnvSettings :: Parser cmd -> appEnv -> String -> String -> Maybe VersionSettings -> Maybe String -> CliEnvSettings (cmd :: Type) (appEnv :: Type)
[cliEnvSettingsCmdParser] :: CliEnvSettings (cmd :: Type) (appEnv :: Type) -> Parser cmd
[cliEnvSettingsAppEnv] :: CliEnvSettings (cmd :: Type) (appEnv :: Type) -> appEnv
[cliEnvSettingsHeaderDesc] :: CliEnvSettings (cmd :: Type) (appEnv :: Type) -> String
[cliEnvSettingsProgDesc] :: CliEnvSettings (cmd :: Type) (appEnv :: Type) -> String
[cliEnvSettingsVersionSettings] :: CliEnvSettings (cmd :: Type) (appEnv :: Type) -> Maybe VersionSettings
[cliEnvSettingsAppName] :: CliEnvSettings (cmd :: Type) (appEnv :: Type) -> Maybe String
-- | Default Iris app settings.
defaultCliEnvSettings :: CliEnvSettings () ()
-- | Parser information for the default CLI parser.
module Iris.Cli.ParserInfo
cmdParserInfo :: forall cmd appEnv. CliEnvSettings cmd appEnv -> ParserInfo (Cmd cmd)
-- | Environment of a CLI app.
module Iris.Env
-- | CLI application environment. It contains default settings for every
-- CLI app and parameter
--
-- Has the following type parameters:
--
-- -- putStdoutColouredLn -- (Colourista.formatWith [Colourista.bold, Colourista.green]) -- "my message" --putStdoutColouredLn :: (MonadReader (CliEnv cmd appEnv) m, MonadIO m) => (Text -> Text) -> Text -> m () -- | Print Text to stderr by providing a custom formatting -- function. -- -- This works especially well with the colourista package: -- --
-- putStderrColouredLn -- (Colourista.formatWith [Colourista.bold, Colourista.green]) -- "my message" --putStderrColouredLn :: (MonadReader (CliEnv cmd appEnv) m, MonadIO m) => (Text -> Text) -> Text -> m () -- | Print Text to stdout by providing a custom formatting -- function. Doesn't breaks output line that differs from -- putStdoutColouredLn -- -- This works especially well with the colourista package: -- --
-- putStdoutColoured -- (Colourista.formatWith [Colourista.bold, Colourista.green]) -- "my message" --putStdoutColoured :: (MonadReader (CliEnv cmd appEnv) m, MonadIO m) => (Text -> Text) -> Text -> m () -- | Print Text to stderr by providing a custom formatting -- function. Doesn't breaks output line that differs from -- putStderrColouredLn -- -- This works especially well with the colourista package: -- --
-- putStderrColoured -- (Colourista.formatWith [Colourista.bold, Colourista.green]) -- "my message" --putStderrColoured :: (MonadReader (CliEnv cmd appEnv) m, MonadIO m) => (Text -> Text) -> Text -> m () -- | Functions to handle colouring of the output to terminal. module Iris.Colour -- | CLI options parsing. module Iris.Cli -- | The application monad — CliApp. -- -- Many functions in Iris are polymorphic over any monad that has -- the MonadReader constraint. -- -- Implement your own application monad as a newtype wrapper -- around CliApp in the following way. -- --
-- newtype App a = App
-- { unApp :: Iris.CliApp MyOptions MyEnv a
-- } deriving newtype
-- ( Functor
-- , Applicative
-- , Monad
-- , MonadIO
-- , MonadUnliftIO
-- , MonadReader (Iris.CliEnv MyOptions MyEnv)
-- )
--
module Iris.App
-- | Main monad for your CLI application.
--
-- The type variables are:
--
-- -- app :: App () -- app = ... your main application ... -- -- main :: IO () -- main = runCliApp mySettings (unApp app) --runCliApp :: CliEnvSettings cmd appEnv -> CliApp cmd appEnv a -> IO a -- | Run application by constructing CliEnv settings manually. runCliAppManually :: CliEnv cmd appEnv -> CliApp cmd appEnv a -> IO a instance Control.Monad.IO.Unlift.MonadUnliftIO (Iris.App.CliApp cmd appEnv) instance Control.Monad.Reader.Class.MonadReader (Iris.Env.CliEnv cmd appEnv) (Iris.App.CliApp cmd appEnv) instance Control.Monad.IO.Class.MonadIO (Iris.App.CliApp cmd appEnv) instance GHC.Base.Monad (Iris.App.CliApp cmd appEnv) instance GHC.Base.Applicative (Iris.App.CliApp cmd appEnv) instance GHC.Base.Functor (Iris.App.CliApp cmd appEnv) -- | Utilities to check required tools and their minimal version for a CLI -- app. -- -- Sometimes, your CLI application module Iris.Tool -- | Use this function to require specific CLI tools for your CLI -- application. -- -- The function can be used in the beginning of each command in the -- following way: -- --
-- app :: App () -- app = Iris.asksCliEnv Iris.cliEnvCmd >>= \case -- Download url -> do -- Iris.need ["curl"] -- runDownload url -- Evaluate hs -> do -- Iris.need ["ghc", "cabal"] -- runEvaluate hs ---- -- Throws: ToolCheckException if can't find a tool or if it -- has wrong version. need :: MonadIO m => [Tool] -> m () data Tool Tool :: Text -> Maybe ToolSelector -> Tool [toolName] :: Tool -> Text [toolSelector] :: Tool -> Maybe ToolSelector data ToolSelector ToolSelector :: (Text -> Bool) -> Maybe Text -> ToolSelector [toolSelectorFunction] :: ToolSelector -> Text -> Bool [toolSelectorVersionArg] :: ToolSelector -> Maybe Text defaultToolSelector :: ToolSelector data ToolCheckResult ToolCheckError :: ToolCheckError -> ToolCheckResult ToolOk :: ToolCheckResult data ToolCheckError ToolNotFound :: Text -> ToolCheckError ToolWrongVersion :: Text -> ToolCheckError -- | An exception thrown by need when there's an error requiring a -- tool. newtype ToolCheckException ToolCheckException :: ToolCheckError -> ToolCheckException checkTool :: Tool -> IO ToolCheckResult instance GHC.Classes.Eq Iris.Tool.ToolCheckError instance GHC.Show.Show Iris.Tool.ToolCheckError instance GHC.Classes.Eq Iris.Tool.ToolCheckResult instance GHC.Show.Show Iris.Tool.ToolCheckResult instance GHC.Exception.Type.Exception Iris.Tool.ToolCheckException instance GHC.Classes.Eq Iris.Tool.ToolCheckException instance GHC.Show.Show Iris.Tool.ToolCheckException instance Data.String.IsString Iris.Tool.Tool -- | Iris is a Haskell CLI framework. It contains batteries for -- bulding CLI applications in Haskell by following best-practices. -- -- The library is designed for qualified imports. To use it, -- import like this: -- --
-- import qualified Iris ---- -- To create an CLI application with Iris, you need to do the -- following steps: -- --