hledger-1.11.1: Command-line interface for the hledger accounting tool

Safe HaskellNone
LanguageHaskell2010

Hledger.Cli.Utils

Description

Utilities for top-level modules and ghci. See also Hledger.Read and Hledger.Utils.

Synopsis

Documentation

withJournalDo :: CliOpts -> (CliOpts -> Journal -> IO ()) -> IO () Source #

Parse the user's specified journal file(s) as a Journal, maybe apply some transformations according to options, and run a hledger command with it. Or, throw an error.

writeOutput :: CliOpts -> String -> IO () Source #

Write some output to stdout or to a file selected by --output-file. If the file exists it will be overwritten.

journalTransform :: CliOpts -> Journal -> IO Journal Source #

Apply some transformations to the journal if specified by options. These include:

  • adding forecast transactions (--forecast)
  • converting amounts to market value (--value)
  • pivoting account names (--pivot)
  • anonymising (--anonymise).

journalApplyValue :: ReportOpts -> Journal -> IO Journal Source #

If -V/--value was requested, convert all journal amounts to their market value as of the report end date. Cf http://hledger.org/manual.html#market-value Since 2017/4 we do this early, before commands run, which affects all commands and seems to have the same effect as doing it last on the reported values.

journalAddForecast :: CliOpts -> Journal -> IO Journal Source #

Generate periodic transactions from all periodic transaction rules in the journal. These transactions are added to the in-memory Journal (but not the on-disk file).

They start on or after the day following the latest normal transaction in the journal, or today if there are none. They end on or before the specified report end date, or 180 days from today if unspecified.

journalReload :: CliOpts -> IO (Either String Journal) Source #

Re-read the journal file(s) specified by options, applying any transformations specified by options. Or return an error string. Reads the full journal, without filtering.

journalReloadIfChanged :: CliOpts -> Day -> Journal -> IO (Either String Journal, Bool) Source #

Re-read the option-specified journal file(s), but only if any of them has changed since last read. (If the file is standard input, this will either do nothing or give an error, not tested yet). Returns a journal or error message, and a flag indicating whether it was re-read or not. Like withJournalDo and journalReload, reads the full journal, without filtering.

journalFileIsNewer :: Journal -> IO Bool Source #

Has the journal's main data file changed since the journal was last read ?

journalSpecifiedFileIsNewer :: Journal -> FilePath -> IO Bool Source #

Has the specified file (presumably one of journal's data files) changed since journal was last read ?

fileModificationTime :: FilePath -> IO ClockTime Source #

Get the last modified time of the specified file, or if it does not exist or there is some other error, the current time.

openBrowserOn :: String -> IO ExitCode Source #

Attempt to open a web browser on the given url, all platforms.

writeFileWithBackup :: FilePath -> String -> IO () Source #

Back up this file with a (incrementing) numbered suffix, then overwrite it with this new text, or give an error.

writeFileWithBackupIfChanged :: FilePath -> Text -> IO Bool Source #

Back up this file with a (incrementing) numbered suffix then overwrite it with this new text, or give an error, but only if the text is different from the current file contents, and return a flag indicating whether we did anything.

pivotByOpts :: CliOpts -> Journal -> Journal Source #

Apply the pivot transformation on a journal, if option is present.

anonymiseByOpts :: CliOpts -> Journal -> Journal Source #

Apply the anonymisation transformation on a journal, if option is present