summaryrefslogtreecommitdiff
path: root/src/Trivstream/Options.hs
blob: 1762f60d1704993e3c9e364bb1582e45ac91900f (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
34
35
36
37
38
{-# LANGUAGE TemplateHaskell, OverloadedStrings #-}

module Trivstream.Options
  ( withOptions
  ) where


import Trivstream.Types
import Trivstream.Options.Utils
import Paths_trivstream (version)
import Development.GitRev


import Options.Applicative

import Control.Monad.Reader
import Control.Monad.IO.Class


withOptions :: MonadIO m => ReaderT Configuration m a -> m a
withOptions f = liftIO (execParser options) >>= runReaderT f
  where
    options = options' `info` mconcat [ header $ concat [ "trivstream "
                                                        , show version
                                                        , " - "
                                                        , "A trivial client & server for streaming audio between pulseaudio and jack over udp/tcp"
                                                        ]
                                      , footer $ concat [ "trivstream "
                                                        , show version
                                                        , " (", $(gitBranch), "@", $(gitHash), (if $(gitDirty) then "*" else ""), ")"
                                                        ]
                                      ]
    options' = Configuration <$> argument rCI (help "Mode of operation" <> value def <> showDefault <> metavar "MODE")
                             <*> optional ( undefined
                                          )
                             <*> audioOptions

    audioOptions = undefined