Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Pythia.Internal.ShellApp
Description
This module provides the functionality for running shell commands and parsing the result.
Since: 0.1
Synopsis
- data SimpleShell m err result = MkSimpleShell {}
- runSimple :: forall m err result. (Exception err, MonadThrow m, MonadTypedProcess m) => SimpleShell m err result -> m result
- tryIOs :: MonadCatch m => [m result] -> m result
- runCommand :: (MonadThrow m, MonadTypedProcess m) => Command -> m Text
SimpleShell
data SimpleShell m err result Source #
Type for running a "simple" shell command given by Command
.
The $sel:parser:MkSimpleShell
is used to parse the result.
Since: 0.1
Constructors
MkSimpleShell | |
Instances
(k ~ A_Lens, a ~ Command, b ~ Command) => LabelOptic "command" k (SimpleShell m err result) (SimpleShell m err result) a b Source # | Since: 0.1 |
Defined in Pythia.Internal.ShellApp Methods labelOptic :: Optic k NoIx (SimpleShell m err result) (SimpleShell m err result) a b Source # | |
(k ~ A_Lens, a ~ m Bool, b ~ m Bool) => LabelOptic "isSupported" k (SimpleShell m err result) (SimpleShell m err result) a b Source # | Since: 0.1 |
Defined in Pythia.Internal.ShellApp Methods labelOptic :: Optic k NoIx (SimpleShell m err result) (SimpleShell m err result) a b Source # | |
(k ~ A_Lens, a ~ (Text -> Either err result), b ~ (Text -> Either err result)) => LabelOptic "parser" k (SimpleShell m err result) (SimpleShell m err result) a b Source # | Since: 0.1 |
Defined in Pythia.Internal.ShellApp Methods labelOptic :: Optic k NoIx (SimpleShell m err result) (SimpleShell m err result) a b Source # |
runSimple :: forall m err result. (Exception err, MonadThrow m, MonadTypedProcess m) => SimpleShell m err result -> m result Source #
Runs a simple shell.
Throws:
: if the command is not supported on this system.NotSupportedException
err
: if running the command throwsSomeException
or a parse error is encountered.
Since: 0.1
Trying Multiple IO
tryIOs :: MonadCatch m => [m result] -> m result Source #
Generalized tryAppActions
to any IO
. Has the same semantics
(i.e. returns the first success or throws an exception if none
succeeds) without checking for "support".
Throws:
NoActionsRunException
: if no actions are run (i.e. the list is empty).SomeExceptions
: if at least one command is run yet there were no successes.
Since: 0.1
Utilities
runCommand :: (MonadThrow m, MonadTypedProcess m) => Command -> m Text Source #
Runs a Command
and returns either the text result or error encountered.
This is used by SimpleShell
to run its command before the result is
parsed. This function is exported for convenience.
Throws:
CommandException
: if running the command returnsExitFailure
exit code.
Since: 0.1