🐚 Out of the shell solution for scripting in Haskell
Go to file
2019-07-05 18:56:23 +08:00
src [#8] Add operator to call command without displaying it (#9) 2019-07-05 18:56:23 +08:00
test Create the project 2019-02-23 21:02:45 +08:00
.gitignore Create the project 2019-02-23 21:02:45 +08:00
.stylish-haskell.yaml Create the project 2019-02-23 21:02:45 +08:00
.travis.yml [#6] Upgrade to GHC-8.6.5 (#7) 2019-05-18 00:32:51 +10:00
CHANGELOG.md [#8] Add operator to call command without displaying it (#9) 2019-07-05 18:56:23 +08:00
CONTRIBUTING.md Create the project 2019-02-23 21:02:45 +08:00
LICENSE Create the project 2019-02-23 21:02:45 +08:00
README.lhs [#3] Write usage example in the README (#4) 2019-02-23 22:53:06 +08:00
README.md [#6] Upgrade to GHC-8.6.5 (#7) 2019-05-18 00:32:51 +10:00
shellmet.cabal [#8] Add operator to call command without displaying it (#9) 2019-07-05 18:56:23 +08:00
stack.yaml [#6] Upgrade to GHC-8.6.5 (#7) 2019-05-18 00:32:51 +10:00

shellmet

Build status Hackage MPL-2.0 license Stackage Lts Stackage Nightly

Out of the shell solution for scripting in Haskell. Shellmet provides an easy and convenient way to call shell commands from Haskell programs.

Usage example

This README contains the usage example of the shellmet library. The example is runnable. You can build and execute with the following command:

cabal new-run readme

Setting up

Since this tutorial is written using Literate Haskell, first, let's write all necessary pragmas and imports.

{-# LANGUAGE OverloadedStrings #-}

import Data.Semigroup ((<>))
import Shellmet (($|))

import qualified Data.Text as T

Simple scripting example

Below you can see how easy it is to interact with shell commands in Haskell:

main :: IO ()
main = do
    "echo" ["Starting shellmet readme..."]
    text <- "cat" $| ["README.md"]
    let cnt = T.pack $ show $ length $ T.lines text
    "echo" ["Number of lines in this README: " <> cnt]

And the output is:

⚙  echo 'Starting shellmet readme...'
Starting shellmet readme...
⚙  echo 'Number of lines in this README: 54'
Number of lines in this README: 54