shellmet-0.0.4.0: Out of the shell solution for scripting in Haskell
Copyright(c) 2019-2021 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

Shellmet

Description

This module contains neat utilities to be able to work with shell commands in generic and simple way using just string literals.

>>> "echo" ["Hello", "World!"]
⚙  echo Hello 'World!'
Hello World!
Synopsis

Documentation

($|) :: FilePath -> [Text] -> IO Text infix 5 Source #

Run shell command with given options and return stripped stdout of the executed command.

>>> "echo" $| ["Foo", "Bar"]
"Foo Bar"

($^) :: FilePath -> [Text] -> IO () infix 5 Source #

This operator runs shell command with given options but doesn't print the command itself.

>>> "echo" $^ ["Foo", "Bar"]
Foo Bar

($?) :: IO a -> IO a -> IO a infixl 4 Source #

Do some IO actions when process failed with IOError.

>>> "exit" ["0"] $? putStrLn "Command failed"
⚙  exit 0
>>> "exit" ["1"] $? putStrLn "Command failed"
⚙  exit 1
Command failed

isSuccess :: IO a -> IO Bool Source #

Returns the indicator of if the command succeded or not.

>>> isSuccess $ "echo" ["Hello world!"]
⚙  echo 'Hello world!'
Hello world!
True

Orphan instances

(a ~ [Text], b ~ IO ()) => IsString (a -> b) Source #

This instance is needed to provide functionality to call commands by using simple string literals in IO monad.

>>> "ls" ["-1", "test"]
⚙  ls -1 test
Doctest.hs
Instance details

Methods

fromString :: String -> a -> b #