{-# 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