From f31a65bcd1642b3f042bd906674f4064cfc9362c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 2 Aug 2016 22:42:52 +0200 Subject: Inital work on option parsing --- src/Trivstream/Options.hs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Trivstream/Options.hs (limited to 'src/Trivstream/Options.hs') diff --git a/src/Trivstream/Options.hs b/src/Trivstream/Options.hs new file mode 100644 index 0000000..a777942 --- /dev/null +++ b/src/Trivstream/Options.hs @@ -0,0 +1,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 -- cgit v1.2.3