look at LEDGER_FILE for the journal path, otherwise LEDGER, like c++ ledger

This commit is contained in:
Simon Michael 2011-04-17 21:26:46 +00:00
parent 505d677461
commit eefae63bb6
2 changed files with 17 additions and 9 deletions

View File

@ -107,14 +107,15 @@ Basic usage is:
$ hledger [OPTIONS] COMMAND [FILTER PATTERNS]
hledger first looks for data in a specially-formatted
[journal file](#file-format). You can specify the file with the -f
option or the `LEDGER` environment variable; otherwise hledger assumes it
is a file named `.journal` in your home directory. If the journal file
[journal file](#file-format). You can specify the file with the `-f`
option or the `LEDGER_FILE` environment variable (`LEDGER` is also
supported for backwards compatibility); otherwise hledger assumes it is a
file named `.hledger.journal` in your home directory. If the journal file
does not exist, it will be auto-created.
To get started, save this
[sample file](http://joyful.com/repos/hledger/data/sample.journal) as
`.journal` in your home directory, or just run `hledger add` and enter
`.hledger.journal` in your home directory, or just run `hledger add` and enter
some transactions. Now try commands like these:
$ hledger add # add some new transactions to the journal file

View File

@ -38,8 +38,9 @@ import System.IO (hGetContents)
#endif
journalenvvar = "LEDGER"
timelogenvvar = "TIMELOG"
journalenvvar = "LEDGER_FILE"
journalenvvar2 = "LEDGER"
timelogenvvar = "TIMELOG"
journaldefaultfilename = ".journal"
timelogdefaultfilename = ".timelog"
@ -111,13 +112,19 @@ emptyJournal = do
readJournal :: Maybe String -> String -> IO (Either String Journal)
readJournal format s = journalFromPathAndString format "(string)" s
-- | Get the user's default journal file path.
-- | Get the user's default journal file path. Like ledger, we look first
-- for the LEDGER_FILE environment variable, and if that does not exist,
-- for the legacy LEDGER environment variable. If neither exists, the path
-- will be ".hledger.journal" in the users's home directory, or if we
-- cannot determine that, in the current directory.
myJournalPath :: IO String
myJournalPath =
getEnv journalenvvar `catch`
(\_ -> do
home <- getHomeDirectory `catch` (\_ -> return "")
return $ home </> journaldefaultfilename)
getEnv journalenvvar2 `catch`
(\_ -> do
home <- getHomeDirectory `catch` (\_ -> return "")
return $ home </> journaldefaultfilename))
-- | Get the user's default timelog file path.
myTimelogPath :: IO String