🐚 Out of the shell solution for scripting in Haskell
Go to file
Dmitrii Kovanikov 217a9b34f6 [#3] Write usage example in the README (#4)
* [#3] Write usage example in the README

Resolves #3

* Fix CI

* Update README.md [skip ci]

Co-Authored-By: ChShersh <kovanikov@gmail.com>

* Update README.md [skip ci]

Co-Authored-By: ChShersh <kovanikov@gmail.com>
2019-02-23 22:53:06 +08:00
src [#3] Write usage example in the README (#4) 2019-02-23 22:53:06 +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 [#1] Implement core library idea (#2) 2019-02-23 22:07:59 +08:00
CHANGELOG.md Create the project 2019-02-23 21:02:45 +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 [#3] Write usage example in the README (#4) 2019-02-23 22:53:06 +08:00
shellmet.cabal [#3] Write usage example in the README (#4) 2019-02-23 22:53:06 +08:00
stack.yaml Create the project 2019-02-23 21:02:45 +08: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