pythia-0.1: A utility program for retrieving system information.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Pythia.Internal.ShellApp

Description

This module provides the functionality for running shell commands and parsing the result.

Since: 0.1

Synopsis

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 

Fields

  • command :: Command

    The shell command to run.

    Since: 0.1

  • isSupported :: m Bool

    Determines if the shell command is supported on this system.

    Since: 0.1

  • parser :: Text -> Either err result

    The parser for the result of running the command.

    Since: 0.1

Instances

Instances details
(k ~ A_Lens, a ~ Command, b ~ Command) => LabelOptic "command" k (SimpleShell m err result) (SimpleShell m err result) a b Source #

Since: 0.1

Instance details

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

Instance details

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

Instance details

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:

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:

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:

Since: 0.1