module Multiarg.Examples.Telly where
import Multiarg
data Telly
= PosArg String
| Empty
| Single String
| Double String String
| Triple String String String
| Zero
| One String
| Two String String
| Three String String String
| Cero
| Uno String
| Dos String String
| Tres String String String
deriving (Eq, Ord, Show)
optSpecs :: [OptSpec Telly]
optSpecs =
[ optSpec "e" ["empty"] (ZeroArg Empty)
, optSpec "s" ["single"] (OneArg Single)
, optSpec "d" ["double"] (TwoArg Double)
, optSpec "t" ["triple"] (ThreeArg Triple)
, optSpec "0" [] (ZeroArg Zero)
, optSpec "1" [] (OneArg One)
, optSpec "2" [] (TwoArg Two)
, optSpec "3" [] (ThreeArg Three)
, optSpec "" ["cero"] (ZeroArg Cero)
, optSpec "" ["uno"] (OneArg Uno)
, optSpec "" ["dos"] (TwoArg Dos)
, optSpec "" ["tres"] (ThreeArg Tres)
]
help :: String -> String
help progName = unlines
[ progName ++ " - simple program to test Multiarg."
, "Parses command line and prints the results to standard output."
, "Usage:"
, progName ++ " [options] ARGUMENTS..."
, ""
, "Options:"
, ""
, "--empty, -e - option that takes no arguments"
, "--single ARG, -s ARG - option that takes one argument"
, "--double ARG1 ARG2, -d ARG1 ARG2 - option that takes two arguments"
, "--triple ARG1 ARG2 ARG3, -t ARG1 ARG2 ARG3"
, " - option that takes three arguments"
, ""
, "--cero - same as --empty"
, "--uno - same as --single"
, "--dos - same as --double"
, "--tres - same as --triple"
, ""
, "--help, -h - show help and exit"
]
parse :: IO [Telly]
parse = parseCommandLine help optSpecs PosArg