mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 20:02:27 +03:00
look at LEDGER_FILE for the journal path, otherwise LEDGER, like c++ ledger
This commit is contained in:
parent
505d677461
commit
eefae63bb6
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user