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

Safe HaskellNone
LanguageHaskell2010

Hledger.Cli.Add

Description

A history-aware add command to help with data entry. |

Synopsis

Documentation

data EntryState Source

State used while entering transactions.

Constructors

EntryState 

Fields

esOpts :: CliOpts

command line options

esArgs :: [String]

command line arguments remaining to be used as defaults

esToday :: Day

today's date

esDefDate :: Day

the default date for next transaction

esJournal :: Journal

the journal we are adding to

esSimilarTransaction :: Maybe Transaction

the most similar historical txn

esPostings :: [Posting]

postings entered so far in the current txn

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

Read multiple transactions from the console, prompting for each field, and append them to the journal file. If the journal came from stdin, this command has no effect.

getAndAddTransactions :: EntryState -> IO () Source

Loop reading transactions from the console, prompting, validating and appending each one to the journal file, until end of input or ctrl-c (then raise an EOF exception). If provided, command-line arguments are used as defaults; otherwise defaults come from the most similar recent transaction in the journal.

completer :: [String] -> String -> CompletionFunc IO Source

Generate a haskeline completion function from the given completions and default, that case insensitively completes with prefix matches, or infix matches above a minimum length, or completes the null string with the default.

green :: [Char] -> [Char] Source

journalAddTransaction :: Journal -> CliOpts -> Transaction -> IO Journal Source

Append this transaction to the journal's file and transaction list.

appendToJournalFileOrStdout :: FilePath -> String -> IO () Source

Append a string, typically one or more transactions, to a journal file, or if the file is "-", dump it to stdout. Tries to avoid excess whitespace.

ensureOneNewlineTerminated :: String -> String Source

Replace a string's 0 or more terminating newlines with exactly one.

registerFromString :: String -> IO String Source

Convert a string of journal data into a register report.

compareStrings :: String -> String -> Double Source

Return a similarity measure, from 0 to 1, for two strings. This is Simon White's letter pairs algorithm from http:/www.catalysoft.comarticles/StrikeAMatch.html with a modification for short strings.

letterPairs :: [t] -> [[t]] Source