summaryrefslogtreecommitdiff
path: root/src/Trivstream/Options.hs
blob: a7779420bb1064c6ecc8d0079a1fb96b30e8deac (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
{-# LANGUAGE TemplateHaskell, OverloadedStrings #-}

module Trivstream.Options
  ( withOptions
  ) where


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


import Options.Applicative

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


withOptions :: MonadIO m => ReaderT Configuration a -> IO 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