hledger-0.22: The main command-line interface for the hledger accounting tool.

Safe Haskell | None

Hledger.Cli.Utils

Description

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

Synopsis

- withJournalDo :: CliOpts -> (CliOpts -> Journal -> IO ()) -> IO ()
- journalReload :: Journal -> IO (Either String Journal)
- journalReloadIfChanged :: CliOpts -> Journal -> IO (Either String Journal, Bool)
- journalFileIsNewer :: Journal -> IO Bool
- journalSpecifiedFileIsNewer :: Journal -> FilePath -> IO Bool
- fileModificationTime :: FilePath -> IO ClockTime
- openBrowserOn :: String -> IO ExitCode
- writeFileWithBackup :: FilePath -> String -> IO ()
- writeFileWithBackupIfChanged :: FilePath -> String -> IO Bool
- readFileStrictly :: FilePath -> IO String
- data Test = TestList [Test]

# Documentation

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

Parse the user's specified journal file and run a hledger command on it, or throw an error.

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

Re-read a journal from its data file, or return an error string.

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

Re-read a journal from its data file mostly, only if the file has changed since last read (or if there is no file, ie data read from stdin). The provided options are mostly ignored. Return a journal or the error message while reading it, and a flag indicating whether it was re-read or not.

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 -> String -> 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.

readFileStrictly :: FilePath -> IO String Source

data Test

The basic structure used to create an annotated tree of test cases.

Constructors

TestList [Test] | A set of `Test`s sharing the same level in the hierarchy.

Instances

Show Test |
Testable Test |