Safe Haskell | None |
---|
A history-aware add command to help with data entry.
Note: this might not be sensible, but add has some aspirations of being both user-friendly and pipeable/scriptable and for this reason informational messages are mostly written to stderr rather than stdout.
- add :: CliOpts -> Journal -> IO ()
- getAndAddTransactionsLoop :: Journal -> CliOpts -> String -> [String] -> IO ()
- getTransaction :: Journal -> CliOpts -> String -> [String] -> IO Transaction
- getTransactionOrRestart :: Journal -> CliOpts -> String -> [String] -> IO (Maybe Transaction)
- data RestartEntryException = RestartEntryException
- data PostingsState = PostingsState {
- psJournal :: Journal
- psAccept :: AccountName -> Bool
- psSuggestHistoricalAmount :: Bool
- psHistory :: Maybe [Posting]
- getPostingsForTransactionWithHistory :: Journal -> CliOpts -> String -> String -> String -> String -> [String] -> IO (Maybe Transaction)
- getPostingsLoop :: PostingsState -> [Posting] -> [String] -> IO [Posting]
- askFor :: String -> Maybe String -> Maybe (String -> Bool) -> InputT IO String
- journalAddTransaction :: Journal -> CliOpts -> Transaction -> IO Journal
- appendToJournalFileOrStdout :: FilePath -> String -> IO ()
- ensureOneNewlineTerminated :: String -> String
- registerFromString :: String -> IO String
- compareStrings :: String -> String -> Double
- wordLetterPairs :: String -> [[Char]]
- letterPairs :: [t] -> [[t]]
- compareDescriptions :: [Char] -> [Char] -> Double
- transactionsSimilarTo :: Journal -> Query -> String -> [(Double, Transaction)]
- runInteraction :: Journal -> InputT IO a -> IO a
- runInteractionDefault :: InputT IO a -> IO a
- type CompletionCache = [AccountName]
- completionCache :: Journal -> CompletionCache
- accountCompletion :: CompletionCache -> CompletionFunc IO
- capitalize :: String -> String
- headTailDef :: a -> [a] -> (a, [a])
Documentation
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.
getAndAddTransactionsLoop :: Journal -> CliOpts -> String -> [String] -> IO ()Source
Loop reading transactions from the console, prompting for, validating, displaying 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 for the first transaction; otherwise defaults come from the most similar recent transaction in the journal.
getTransaction :: Journal -> CliOpts -> String -> [String] -> IO TransactionSource
Read a single transaction from the console, with history-aware prompting, allowing the user to restart and confirm at the end. A default date, and zero or more defaults for subsequent fields, are provided.
getTransactionOrRestart :: Journal -> CliOpts -> String -> [String] -> IO (Maybe Transaction)Source
Read a single transaction from the console, with history-aware prompting, or return nothing indicating that the user wants to restart entering this transaction. A default date, and zero or more defaults for subsequent fields, are provided.
data PostingsState Source
Information used as the basis for suggested account names, amounts etc. in add prompt.
PostingsState | |
|
getPostingsForTransactionWithHistory :: Journal -> CliOpts -> String -> String -> String -> String -> [String] -> IO (Maybe Transaction)Source
Loop reading postings from the console, until a valid balanced set of postings has been entered, then return the final transaction, or nothing indicating that the user wants to restart entering this transaction.
getPostingsLoop :: PostingsState -> [Posting] -> [String] -> IO [Posting]Source
Read postings from the command line until . is entered, generating useful defaults based on historical context and postings entered so far.
askFor :: String -> Maybe String -> Maybe (String -> Bool) -> InputT IO StringSource
Prompt for and read a string value, optionally with a default value and a validator. A validator causes the prompt to repeat until the input is valid. May also raise an EOF exception if control-d or control-c is pressed.
journalAddTransaction :: Journal -> CliOpts -> Transaction -> IO JournalSource
Append this transaction to the journal's file, and to the journal's 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 -> StringSource
Replace a string's 0 or more terminating newlines with exactly one.
registerFromString :: String -> IO StringSource
Convert a string of journal data into a register report.
compareStrings :: String -> String -> DoubleSource
Return a similarity measure, from 0 to 1, for two strings. This is Simon White's letter pairs algorithm from http:www.catalysoft.comarticlesStrikeAMatch.html with a modification for short strings.
wordLetterPairs :: String -> [[Char]]Source
letterPairs :: [t] -> [[t]]Source
compareDescriptions :: [Char] -> [Char] -> DoubleSource
transactionsSimilarTo :: Journal -> Query -> String -> [(Double, Transaction)]Source
runInteractionDefault :: InputT IO a -> IO aSource
type CompletionCache = [AccountName]Source
capitalize :: String -> StringSource
headTailDef :: a -> [a] -> (a, [a])Source