-- 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: -- -- -- -- Throws: BrowseException if can't find a browser. openInBrowser :: FilePath -> IO () -- | Exception thrown by openInBrowser. newtype BrowseException -- | Can't find a browser application. Stores the current OS inside. BrowserNotFoundException :: String -> BrowseException instance GHC.Exception.Type.Exception Iris.Browse.BrowseException instance GHC.Classes.Eq Iris.Browse.BrowseException instance GHC.Show.Show Iris.Browse.BrowseException -- | CLI options parsing for --browse and -- --browse=FILE_PATH. module Iris.Cli.Browse -- | A CLI option parser yields a boolean value if a file needs to be open -- in a browser. -- -- Use openInBrowser to open the file of your choice in a browser. browseP :: String -> Parser Bool -- | A CLI option parser for a FilePath that needs to be open with a -- browser. -- -- Use openInBrowser to open the passed file in a browser. browseFileP :: String -> Parser FilePath -- | CLI parser for the --colour and --no-colour options. module Iris.Cli.Colour -- | Data type that tells whether the user wants the colouring option -- enabled, disabled or autodetected. -- -- See colourOptionP for the parser of this option. data ColourOption Always :: ColourOption Never :: ColourOption Auto :: ColourOption -- | A CLI option parser for the desired coloured output mode in the -- terminal. -- -- It parses --colour and --no-colour flags explicitly. -- Otherwise, it defaults to Auto. colourOptionP :: Parser ColourOption instance GHC.Enum.Bounded Iris.Cli.Colour.ColourOption instance GHC.Enum.Enum Iris.Cli.Colour.ColourOption instance GHC.Classes.Ord Iris.Cli.Colour.ColourOption instance GHC.Classes.Eq Iris.Cli.Colour.ColourOption instance GHC.Show.Show Iris.Cli.Colour.ColourOption -- | Interactive mode datatype and CLI parser. module Iris.Cli.Interactive -- | Datatype for specifying if the terminal is interactive. data InteractiveMode Interactive :: InteractiveMode NonInteractive :: InteractiveMode -- | A CLI option parser for switching to non-interactive mode if the -- --no-input flag is passed. interactiveModeP :: Parser InteractiveMode -- | Forces non interactive mode when the terminal is not interactive -- -- Use this function to check whether you can get input from the -- terminal: -- --
--   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:__ -- -- -- -- ℹ️ Iris performs this check on the application start automatically so -- you don't need to call this function manually. detectColourMode :: Handle -> ColourOption -> Maybe String -> IO ColourMode -- | Returns ColourMode of a Handle ignoring environment and -- CLI options. You can use this function on output Handles to -- find out whether they support colouring or not. -- -- Use a function like this to check whether you can print with colour to -- terminal: -- --
--   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: -- -- data CliEnv (cmd :: Type) (appEnv :: Type) CliEnv :: cmd -> ColourMode -> ColourMode -> appEnv -> InteractiveMode -> CliEnv (cmd :: Type) (appEnv :: Type) [cliEnvCmd] :: CliEnv (cmd :: Type) (appEnv :: Type) -> cmd [cliEnvStdoutColourMode] :: CliEnv (cmd :: Type) (appEnv :: Type) -> ColourMode [cliEnvStderrColourMode] :: CliEnv (cmd :: Type) (appEnv :: Type) -> ColourMode [cliEnvAppEnv] :: CliEnv (cmd :: Type) (appEnv :: Type) -> appEnv [cliEnvInteractiveMode] :: CliEnv (cmd :: Type) (appEnv :: Type) -> InteractiveMode mkCliEnv :: forall cmd appEnv. CliEnvSettings cmd appEnv -> IO (CliEnv cmd appEnv) -- | Get a field from the global environment CliEnv. asksCliEnv :: MonadReader (CliEnv cmd appEnv) m => (CliEnv cmd appEnv -> field) -> m field -- | Get a field from custom application-specific environment -- appEnv. asksAppEnv :: MonadReader (CliEnv cmd appEnv) m => (appEnv -> field) -> m field -- | Helper functions to print with colouring. module Iris.Colour.Formatting -- | Print Text to stdout by providing a custom formatting -- function. -- -- This works especially well with the colourista package: -- --
--   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: -- -- newtype CliApp cmd appEnv a CliApp :: (CliEnv cmd appEnv -> IO a) -> CliApp cmd appEnv a [unCliApp] :: CliApp cmd appEnv a -> CliEnv cmd appEnv -> IO a -- | Run application with settings. -- -- This function is supposed to be used in your main function: -- --
--   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: -- --
    --
  1. Create settings for your applications by constructing a value of -- type CliEnvSettings.
  2. --
  3. Define a monad for your application with the help of CliApp -- by using either type or newtype.
  4. --
-- -- That's all! Now, you can write your CLI app by having access to all -- capabilities provided by Iris 🎉 -- -- For a detailed introduction to Iris, refer to the following -- examples: -- -- module Iris