diff options
author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-08-02 22:42:52 +0200 |
---|---|---|
committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-08-02 22:42:52 +0200 |
commit | f31a65bcd1642b3f042bd906674f4064cfc9362c (patch) | |
tree | b99f2180b38a2a3280f63dc9f521785fe3736578 /src/Trivstream/Options.hs | |
parent | d6647e7fc48c6436dc74c99b4614aa2bb557ea75 (diff) | |
download | trivstream-f31a65bcd1642b3f042bd906674f4064cfc9362c.tar trivstream-f31a65bcd1642b3f042bd906674f4064cfc9362c.tar.gz trivstream-f31a65bcd1642b3f042bd906674f4064cfc9362c.tar.bz2 trivstream-f31a65bcd1642b3f042bd906674f4064cfc9362c.tar.xz trivstream-f31a65bcd1642b3f042bd906674f4064cfc9362c.zip |
Inital work on option parsing
Diffstat (limited to 'src/Trivstream/Options.hs')
-rw-r--r-- | src/Trivstream/Options.hs | 37 |
1 files changed, 37 insertions, 0 deletions
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 @@ | |||
1 | {-# LANGUAGE TemplateHaskell, OverloadedStrings #-} | ||
2 | |||
3 | module Trivstream.Options | ||
4 | ( withOptions | ||
5 | ) where | ||
6 | |||
7 | |||
8 | import Trivstream.Types | ||
9 | import Trivstream.Options.Utils | ||
10 | import Paths_trivstream (version) | ||
11 | |||
12 | |||
13 | import Options.Applicative | ||
14 | |||
15 | import Control.Monad.Reader | ||
16 | import Control.Monad.IO.Class | ||
17 | |||
18 | |||
19 | withOptions :: MonadIO m => ReaderT Configuration a -> IO a | ||
20 | withOptions f = liftIO (execParser options) >>= runReaderT f | ||
21 | where | ||
22 | options = options' `info` mconcat [ header $ concat [ "trivstream " | ||
23 | , show version | ||
24 | , " - " | ||
25 | , "A trivial client & server for streaming audio between pulseaudio and jack over udp/tcp" | ||
26 | ] | ||
27 | , footer $ concat [ "trivstream " | ||
28 | , show version | ||
29 | , " (", $(gitBranch), "@", $(gitHash), (if $(gitDirty) then "*" else ""), ")" | ||
30 | ] | ||
31 | ] | ||
32 | options' = Configuration <$> argument rCI (help "Mode of operation" <> value def <> showDefault <> metavar "MODE") | ||
33 | <*> optional ( undefined | ||
34 | ) | ||
35 | <*> audioOptions | ||
36 | |||
37 | audioOptions = undefined | ||