Example usage of this module:
-- options.hs
{-# LANGUAGE OverloadedStrings #-}
import Turtle
parser :: Parser (Text, Int)
parser = (,) <$> optText "name" 'n' "Your first name"
<*> optInt "age" 'a' "Your current age"
main = do
(name, age) <- options "Greeting script" parser
echo (repr (format ("Hello there, "%s) name))
echo (repr (format ("You are "%d%" years old") age))
$ ./options --name John --age 42
Hello there, John
You are 42 years old
$ ./options --help
Greeting script
Usage: options (-n|--name NAME) (-a|--age AGE)
Available options:
-h,--help Show this help text
--name NAME Your first name
--age AGE Your current age
See the
Turtle.Tutorial module which contains more examples on
how to use command-line parsing.