Parsing of separator

This commit is contained in:
Luca Molteni 2018-06-21 22:11:11 +02:00
parent f7a61737f1
commit 4fc2374b2b
2 changed files with 6 additions and 2 deletions

View File

@ -17,7 +17,8 @@ module Hledger.Data.RawOptions (
maybestringopt,
listofstringopt,
intopt,
maybeintopt
maybeintopt,
maybecharopt
)
where
@ -50,6 +51,9 @@ maybestringopt name = maybe Nothing (Just . T.unpack . stripquotes . T.pack) . l
stringopt :: String -> RawOpts -> String
stringopt name = fromMaybe "" . maybestringopt name
maybecharopt :: String -> RawOpts -> Maybe Char
maybecharopt name rawopts = lookup name rawopts >>= readMay
listofstringopt :: String -> RawOpts -> [String]
listofstringopt name rawopts = [v | (k,v) <- rawopts, k==name]

View File

@ -178,7 +178,7 @@ rawOptsToInputOpts rawopts = InputOpts{
-- files_ = map (T.unpack . stripquotes . T.pack) $ listofstringopt "file" rawopts
mformat_ = Nothing
,mrules_file_ = maybestringopt "rules-file" rawopts
,separator_ = ','
,separator_ = fromMaybe ',' (maybecharopt "separator" rawopts)
,aliases_ = map (T.unpack . stripquotes . T.pack) $ listofstringopt "alias" rawopts
,anon_ = boolopt "anon" rawopts
,ignore_assertions_ = boolopt "ignore-assertions" rawopts