aboutsummaryrefslogtreecommitdiff
path: root/src/CommandLineOptions.hs
blob: 2a1f5858545f70bd16e38e375a50e3cc475089c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module CommandLineOptions
  ( Sample(..)
  , getOptions
  ) where

import Options.Applicative

data Sample = Sample
  { hello :: String
  , quiet :: Bool
  }

getOptions :: IO Sample
getOptions =
  execParser $ info
    (helper <*> sample)
    (  fullDesc
    <> progDesc "Print a greeting for TARGET"
    <> header "hello - a test for optparse-applicative"
    )

sample :: Parser Sample
sample =
  Sample
    <$> strOption
      (  long "name"
      <> metavar "TARGET"
      <> help "Target for the greeting"
      )
    <*> switch
      (  long "quiet"
      <> help "Whether to be quiet"
      )