cli: give literal tilde error also with -f
This commit is contained in:
parent
f5eecc34a3
commit
556e3c9246
@ -137,7 +137,6 @@ readJournal format s = journalFromPathAndString format "(string)" s
|
||||
myJournalPath :: IO String
|
||||
myJournalPath = do
|
||||
s <- envJournalPath
|
||||
errorIfContainsTilde s
|
||||
if null s then defaultJournalPath else return s
|
||||
where
|
||||
envJournalPath = getEnv journalenvvar `catch` (\_ -> getEnv journalenvvar2 `catch` (\_ -> return ""))
|
||||
@ -145,8 +144,6 @@ myJournalPath = do
|
||||
home <- getHomeDirectory `catch` (\_ -> return "")
|
||||
return $ home </> journaldefaultfilename
|
||||
|
||||
errorIfContainsTilde s = when ('~' `elem` s) $ error' "unsupported literal ~ found in environment variable, please adjust"
|
||||
|
||||
-- | Get the user's default timelog file path.
|
||||
myTimelogPath :: IO String
|
||||
myTimelogPath =
|
||||
|
||||
@ -423,11 +423,15 @@ defaultBalanceFormatString = [
|
||||
, FormatField True Nothing Nothing Format.Account
|
||||
]
|
||||
|
||||
-- | Get the journal file path from options, an environment variable, or a default
|
||||
-- | Get the journal file path from options, an environment variable, or a default.
|
||||
-- If the path contains a literal tilde raise an error to avoid confusion.
|
||||
journalFilePathFromOpts :: CliOpts -> IO String
|
||||
journalFilePathFromOpts opts = do
|
||||
f <- myJournalPath
|
||||
return $ fromMaybe f $ file_ opts
|
||||
return $ errorIfContainsTilde $ fromMaybe f $ file_ opts
|
||||
|
||||
errorIfContainsTilde s |'~' `elem` s = error' "unsupported literal ~ found in environment variable, please adjust"
|
||||
| otherwise = s
|
||||
|
||||
aliasesFromOpts :: CliOpts -> [(AccountName,AccountName)]
|
||||
aliasesFromOpts = map parseAlias . alias_
|
||||
|
||||
Loading…
Reference in New Issue
Block a user