make --rules-file work again
This commit is contained in:
parent
70572eb837
commit
ed1ea545f5
@ -124,7 +124,7 @@ generalflags3 = helpflags
|
|||||||
|
|
||||||
fileflags = [
|
fileflags = [
|
||||||
flagReq ["file","f"] (\s opts -> Right $ setopt "file" s opts) "FILE" "use a different journal file; - means stdin"
|
flagReq ["file","f"] (\s opts -> Right $ setopt "file" s opts) "FILE" "use a different journal file; - means stdin"
|
||||||
,flagReq ["rules-file"] (\s opts -> Right $ setopt "rules-file" s opts) "FILE" "conversion rules file for CSV (default: FILE.rules)"
|
,flagReq ["rules-file"] (\s opts -> Right $ setopt "rules-file" s opts) "RULESFILE" "conversion rules for CSV (default: FILE.rules)"
|
||||||
,flagReq ["alias"] (\s opts -> Right $ setopt "alias" s opts) "ACCT=ALIAS" "display ACCT's name as ALIAS in reports"
|
,flagReq ["alias"] (\s opts -> Right $ setopt "alias" s opts) "ACCT=ALIAS" "display ACCT's name as ALIAS in reports"
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -466,6 +466,16 @@ journalFilePathFromOpts opts = do
|
|||||||
then error' $ printf "~ in the journal file path is not supported, please adjust (%s)" f'
|
then error' $ printf "~ in the journal file path is not supported, please adjust (%s)" f'
|
||||||
else return f'
|
else return f'
|
||||||
|
|
||||||
|
-- | Get the rules file path from options, if any.
|
||||||
|
-- If the path contains a literal tilde raise an error to avoid confusion. XXX
|
||||||
|
rulesFilePathFromOpts :: CliOpts -> Maybe FilePath
|
||||||
|
rulesFilePathFromOpts opts =
|
||||||
|
case rules_file_ opts of
|
||||||
|
Nothing -> Nothing
|
||||||
|
Just f -> if '~' `elem` f
|
||||||
|
then error' $ printf "~ in file paths is not supported, please adjust (%s)" f
|
||||||
|
else Just f
|
||||||
|
|
||||||
aliasesFromOpts :: CliOpts -> [(AccountName,AccountName)]
|
aliasesFromOpts :: CliOpts -> [(AccountName,AccountName)]
|
||||||
aliasesFromOpts = map parseAlias . alias_
|
aliasesFromOpts = map parseAlias . alias_
|
||||||
where
|
where
|
||||||
|
|||||||
@ -48,7 +48,7 @@ withJournalDo opts cmd = do
|
|||||||
-- We kludgily read the file before parsing to grab the full text, unless
|
-- We kludgily read the file before parsing to grab the full text, unless
|
||||||
-- it's stdin, or it doesn't exist and we are adding. We read it strictly
|
-- it's stdin, or it doesn't exist and we are adding. We read it strictly
|
||||||
-- to let the add command work.
|
-- to let the add command work.
|
||||||
journalFilePathFromOpts opts >>= readJournalFile Nothing Nothing >>=
|
journalFilePathFromOpts opts >>= readJournalFile Nothing (rulesFilePathFromOpts opts) >>=
|
||||||
either error' (cmd opts . journalApplyAliases (aliasesFromOpts opts))
|
either error' (cmd opts . journalApplyAliases (aliasesFromOpts opts))
|
||||||
|
|
||||||
-- -- | Get a journal from the given string and options, or throw an error.
|
-- -- | Get a journal from the given string and options, or throw an error.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user