-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptions.hs
44 lines (40 loc) · 1 KB
/
Options.hs
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
39
40
41
42
43
44
module Options
( Options (..)
, getOptions
) where
import Options.Applicative
data Options = Options
{ optionsHost :: String
, optionsPort :: Int
, optionsAccountsPath :: String
, optionsDatabasePath :: String
}
optionsParser :: Parser Options
optionsParser = Options
<$> option str
(long "host"
<> metavar "HOST"
<> help "Host to listen on"
<> value "127.0.0.1"
<> showDefault)
<*> option auto
(long "port"
<> metavar "PORT"
<> help "Port to listen on"
<> value 7123
<> showDefault)
<*> option str
(long "accounts"
<> metavar "PATH"
<> help "Account list path"
<> value "localscrobble-accounts.txt"
<> showDefault)
<*> option str
(long "database"
<> metavar "PATH"
<> help "Database path"
<> value "localscrobble.db"
<> showDefault)
getOptions :: IO Options
getOptions = execParser $ info (optionsParser <**> helper)
(fullDesc <> header "localscrobble - local scrobbling server")