-- 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.0.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:
--
--
-- - Check the BROWSER environment variable
-- - If it's not set, try to guess browser depending on OS
-- - If unsuccsessful, print a message
--
--
-- 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
-- | Interative mode datatype and CLI parser.
module Iris.Cli.Interactive
data InteractiveMode
Interactive :: InteractiveMode
NonInteractive :: InteractiveMode
-- | A CLI option parser for switching to non-interactive mode if the flag
-- is passed.
interactiveModeP :: Parser InteractiveMode
instance GHC.Classes.Eq Iris.Cli.Interactive.InteractiveMode
instance GHC.Show.Show Iris.Cli.Interactive.InteractiveMode
-- | 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)
-- | CLI options parsing.
module Iris.Cli
-- | 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
-- | Returns ColourMode of a Handle. 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
-- | Utilities to check required tools and their minimal version for a CLI
-- app.
module Iris.Tool
data Tool cmd
Tool :: Text -> Maybe (ToolSelector cmd) -> Tool cmd
[toolName] :: Tool cmd -> Text
[toolSelector] :: Tool cmd -> Maybe (ToolSelector cmd)
data ToolSelector cmd
ToolSelector :: (cmd -> Text -> Bool) -> Maybe Text -> ToolSelector cmd
[toolSelectorFunction] :: ToolSelector cmd -> cmd -> Text -> Bool
[toolSelectorVersionArg] :: ToolSelector cmd -> Maybe Text
defaultToolSelector :: ToolSelector cmd
data ToolCheckResult
ToolNotFound :: Text -> ToolCheckResult
ToolWrongVersion :: Text -> ToolCheckResult
ToolOk :: ToolCheckResult
checkTool :: cmd -> Tool cmd -> IO ToolCheckResult
instance GHC.Classes.Eq Iris.Tool.ToolCheckResult
instance GHC.Show.Show Iris.Tool.ToolCheckResult
instance Data.String.IsString (Iris.Tool.Tool cmd)
-- | Environment of a CLI app.
module Iris.Env
data CliEnvSettings (cmd :: Type) (appEnv :: Type)
CliEnvSettings :: Parser cmd -> appEnv -> String -> String -> Maybe VersionSettings -> [Tool cmd] -> 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
[cliEnvSettingsRequiredTools] :: CliEnvSettings (cmd :: Type) (appEnv :: Type) -> [Tool cmd]
defaultCliEnvSettings :: CliEnvSettings () ()
-- | CLI application environment. It contains default settings for every
-- CLI app and parameter
--
-- Has the following type parameters:
--
--
-- - cmd — application commands
-- - appEnv — application-specific environment; use
-- () if you don't have custom app environment
--
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
newtype CliEnvException
CliEnvException :: CliEnvError -> CliEnvException
[unCliEnvException] :: CliEnvException -> CliEnvError
newtype CliEnvError
CliEnvToolError :: ToolCheckResult -> CliEnvError
-- | Throws: CliEnvException
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
instance GHC.Classes.Eq Iris.Env.CliEnvError
instance GHC.Show.Show Iris.Env.CliEnvError
instance GHC.Exception.Type.Exception Iris.Env.CliEnvException
instance GHC.Classes.Eq Iris.Env.CliEnvException
instance GHC.Show.Show Iris.Env.CliEnvException
-- | Helper functions to print with colouring.
module Iris.Colour.Formatting
-- | Print ByteString 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) => (ByteString -> ByteString) -> ByteString -> m ()
-- | Print ByteString 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) => (ByteString -> ByteString) -> ByteString -> m ()
-- | Functions to handle colouring of the output to terminal.
module Iris.Colour
-- | Haskell CLI framework
module Iris.App
-- | Main monad for your CLI application.
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.
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)
-- | 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:
--
--
-- - Create settings for your applications by constructing a value of
-- type CliEnvSettings.
-- - Define a monad for your application with the help of CliApp
-- by using either type or newtype.
--
--
-- That's all! Now, you can write your CLI app by having access to all
-- capabilities provided by Iris 🎉
module Iris