-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Miscellaneous utilities for building and working with command line interfaces
--
-- Convenience functions for writing command line interfaces, providing
-- facilities for logging, process management, and printing to the
-- terminal.
@package cli-extras
@version 0.1.0.2
module Bindings.Cli.Coreutils
cp :: FilePath
module Cli.Extras.SubExcept
-- | Wrap a Prism' in a newtype to avoid impredicativity problems
newtype WrappedPrism' a b
WrappedPrism' :: Prism' a b -> WrappedPrism' a b
[unWrappedPrism'] :: WrappedPrism' a b -> Prism' a b
newtype SubExceptT e eSub m a
SubExceptT :: ReaderT (WrappedPrism' e eSub) m a -> SubExceptT e eSub m a
[unSubExceptT] :: SubExceptT e eSub m a -> ReaderT (WrappedPrism' e eSub) m a
runSubExceptT :: Prism' e eSub -> SubExceptT e eSub m a -> m a
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Cli.Extras.SubExcept.SubExceptT e eSub m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Cli.Extras.SubExcept.SubExceptT e eSub m)
instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (Cli.Extras.SubExcept.SubExceptT e eSub m)
instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Cli.Extras.SubExcept.SubExceptT e eSub m)
instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Cli.Extras.SubExcept.SubExceptT e eSub m)
instance GHC.Base.Monad m => GHC.Base.Monad (Cli.Extras.SubExcept.SubExceptT e eSub m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Cli.Extras.SubExcept.SubExceptT e eSub m)
instance GHC.Base.Functor m => GHC.Base.Functor (Cli.Extras.SubExcept.SubExceptT e eSub m)
instance Control.Monad.Log.MonadLog o m => Control.Monad.Log.MonadLog o (Cli.Extras.SubExcept.SubExceptT e eSub m)
instance Control.Monad.Trans.Class.MonadTrans (Cli.Extras.SubExcept.SubExceptT e eSub)
instance Control.Monad.Error.Class.MonadError e m => Control.Monad.Error.Class.MonadError eSub (Cli.Extras.SubExcept.SubExceptT e eSub m)
-- | |
module Cli.Extras
type CliLog m = MonadLog Output m
type CliThrow e m = MonadError e m
newtype CliT e m a
CliT :: ReaderT CliConfig (LoggingT Output (ExceptT e m)) a -> CliT e m a
[unCliT] :: CliT e m a -> ReaderT CliConfig (LoggingT Output (ExceptT e m)) a
runCli :: MonadIO m => CliConfig -> CliT e m a -> m (Either e a)
data CliConfig
class Monad m => HasCliConfig m
getCliConfig :: HasCliConfig m => m CliConfig
data Output
-- | Run an action with a CLI spinner.
withSpinner :: (MonadIO m, MonadMask m, CliLog m, HasCliConfig m) => Text -> m a -> m a
-- | A spinner that leaves no trail after a successful run.
--
-- Use if you wish the spinner to be ephemerally visible to the user.
--
-- The 'no trail' property automatically carries over to sub-spinners (in
-- that they won't leave a trail either).
withSpinnerNoTrail :: (MonadIO m, MonadMask m, CliLog m, HasCliConfig m) => Text -> m a -> m a
-- | Advanced version that controls the display and content of the trail
-- message.
withSpinner' :: (MonadIO m, MonadMask m, CliLog m, HasCliConfig m) => Text -> Maybe (a -> Text) -> m a -> m a
-- | Indicates unstructured errors form one variant (or conceptual
-- projection) of the error type.
--
-- Shouldn't really use this, but who has time to clean up that much!
class AsUnstructuredError e
asUnstructuredError :: AsUnstructuredError e => Prism' e Text
newCliConfig :: Severity -> Bool -> Bool -> IO CliConfig
mkDefaultCliConfig :: [String] -> IO CliConfig
getLogLevel :: (MonadIO m, HasCliConfig m) => m Severity
-- | Log a message to the console.
--
-- Logs safely even if there are ongoing spinners.
putLog :: CliLog m => Severity -> Text -> m ()
-- | Like `putLog Alert` but also abrupts the program.
failWith :: (CliThrow e m, AsUnstructuredError e) => Text -> m a
-- | Intercept ExitFailure exceptions and log the given alert before
-- exiting.
--
-- This is useful when you want to provide contextual information to a
-- deeper failure.
withExitFailMessage :: (CliLog m, MonadCatch m) => Text -> m a -> m a
-- | Classes of severity for log messages. These have been chosen to match
-- syslog severity levels
data Severity
-- | System is unusable. By syslog convention, this level should
-- not be used by applications.
Emergency :: Severity
-- | Should be corrected immediately.
Alert :: Severity
-- | Critical conditions.
Critical :: Severity
-- | Error conditions.
Error :: Severity
-- | May indicate that an error will occur if action is not taken.
Warning :: Severity
-- | Events that are unusual, but not error conditions.
Notice :: Severity
-- | Normal operational messages that require no action.
Informational :: Severity
-- | Information useful to developers for debugging the application.
Debug :: Severity
-- | Indicates arbitrary process failures form one variant (or conceptual
-- projection) of the error type.
class AsProcessFailure e
asProcessFailure :: AsProcessFailure e => Prism' e ProcessFailure
data ProcessFailure
ProcessFailure :: CmdSpec -> Int -> ProcessFailure
prettyProcessFailure :: ProcessFailure -> Text
data ProcessSpec
ProcessSpec :: !CreateProcess -> !Maybe (Map String String -> Map String String) -> ProcessSpec
[_processSpec_createProcess] :: ProcessSpec -> !CreateProcess
[_processSpec_overrideEnv] :: ProcessSpec -> !Maybe (Map String String -> Map String String)
-- | Like callCommand but also logs (debug) the command being run
callCommand :: (MonadIO m, CliLog m) => String -> m ()
-- | Like callProcess but also logs (debug) the process being run
callProcess :: (MonadIO m, CliLog m) => String -> [String] -> m ()
-- | Like callProcess but logs the combined output (stdout and
-- stderr) with the corresponding severity.
--
-- Usually this function is called as `callProcessAndLogOutput (Debug,
-- Error)`. However some processes are known to spit out diagnostic or
-- informative messages in stderr, in which case it is advisable to call
-- it with a non-Error severity for stderr, like `callProcessAndLogOutput
-- (Debug, Debug)`.
callProcessAndLogOutput :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m) => (Severity, Severity) -> ProcessSpec -> m ()
-- | Like createProcess_ but also logs (debug) the process being run
createProcess_ :: (MonadIO m, CliLog m) => String -> ProcessSpec -> m (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
overCreateProcess :: (CreateProcess -> CreateProcess) -> ProcessSpec -> ProcessSpec
proc :: FilePath -> [String] -> ProcessSpec
readCreateProcessWithExitCode :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e) => ProcessSpec -> m (ExitCode, String, String)
-- | Like readProcess but logs the combined output (stdout and
-- stderr) with the corresponding severity.
--
-- Usually this function is called as `callProcessAndLogOutput (Debug,
-- Error)`. However some processes are known to spit out diagnostic or
-- informative messages in stderr, in which case it is advisable to call
-- it with a non-Error severity for stderr, like `callProcessAndLogOutput
-- (Debug, Debug)`.
readProcessAndLogOutput :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m) => (Severity, Severity) -> ProcessSpec -> m Text
readProcessAndLogStderr :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m) => Severity -> ProcessSpec -> m Text
readProcessJSONAndLogStderr :: (FromJSON a, MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m) => Severity -> ProcessSpec -> m a
-- | Pretty print a CmdSpec
reconstructCommand :: CmdSpec -> Text
setCwd :: Maybe FilePath -> ProcessSpec -> ProcessSpec
setDelegateCtlc :: Bool -> ProcessSpec -> ProcessSpec
setEnvOverride :: (Map String String -> Map String String) -> ProcessSpec -> ProcessSpec
shell :: String -> ProcessSpec
-- | Wrapper around waitForProcess
waitForProcess :: MonadIO m => ProcessHandle -> m ExitCode