#!/usr/bin/env ./go
{-# LANGUAGE OverloadedStrings #-}
import Turtle
The readme that builds itself!
You can setup and build this project by running this very readme. This is what the CI job does!
Example: ./README.lhs --setup --test
parser :: Parser (Bool, Bool, Bool)
parser = (,,) <$> switch "setup" 's' "Set up the stack environment."
<*> switch "test" 't' "Build the project and run the tests."
<*> switch "build" 'b' "Just build, don't run tests."
main = void $ do
(setup, test, build) <- options "Literate README" parser
let ops = doSetup setup .&&. doBuild build .&&. doTest test
ops .||. die "Step failed."
nop = shell "true" empty
stackOrNop op True = shell ("stack " <> op) empty
stackOrNop _ _ = nop
-- | Call this with: ./README.lhs --setup
doSetup = stackOrNop "setup"
-- | Call this with: ./README.lhs --build
doBuild = stackOrNop "build"
-- | Call this with: ./README.lhs --test
doTest = stackOrNop "test"