hledger-lib
Safe HaskellNone
LanguageGHC2021

Hledger.Read.InputOptions

Description

Various options to use when reading journal files. Similar to CliOptions.inputflags, simplifies the journal-reading functions.

Synopsis

Types and helpers for input options

data InputOpts Source #

Constructors

InputOpts 

Fields

  • mformat_ :: Maybe StorageFormat

    a file/storage format to try, unless overridden by a filename prefix. Nothing means try all.

  • mrules_file_ :: Maybe FilePath

    a conversion rules file to use (when reading CSV)

  • aliases_ :: [String]

    account name aliases to apply

  • anon_ :: Bool

    do light obfuscation of the data ? Now corresponds to --obfuscate, not the old --anon flag.

  • new_ :: Bool

    read only new transactions since this file was last read ?

  • new_save_ :: Bool

    save latest new transactions state for next time ?

  • pivot_ :: String

    use the given field's value as the account name

  • forecast_ :: Maybe DateSpan

    span in which to generate forecast transactions

  • verbose_tags_ :: Bool

    add user-visible tags when generating/modifying transactions & postings ?

  • reportspan_ :: DateSpan

    a dirty hack keeping the query dates in InputOpts. This rightfully lives in ReportSpec, but is duplicated here.

  • auto_ :: Bool

    generate extra postings according to auto posting rules ?

  • infer_equity_ :: Bool

    infer equity conversion postings from costs ?

  • infer_costs_ :: Bool

    infer costs from equity conversion postings ? distinct from BalancingOpts{infer_balancing_costs_}

  • ignore_lots_ :: Bool

    skip lot tracking and its checks, silencing lot errors ? (basic lot inference still runs, leniently, so lot entries balance)

  • balancingopts_ :: BalancingOpts

    options for transaction balancing

  • strict_ :: Bool

    do extra correctness checks ?

  • _defer :: Bool

    internal flag: postpone checks, because we are processing multiple files ?

  • _importing :: Bool

    internal flag: is this the import command reading its data files ? Enables the CSV rules reader's import-specific behaviour: preferring the oldest file matched by a source glob, and honouring the archive rule. Set by importcmd; other reads should leave it off.

  • _dryrun :: Bool

    internal flag: is this a import --dry-run command ? If set, the CSV rules reader will never archive or remove a data file.

  • _scanfiles :: Bool

    internal flag: are we just finding the files read (for the files command) ? If set, files are parsed only to find the files they include or use: data is not converted or finalised (balanced, checked), source commands are not run, and an included file which is missing (or a glob matching nothing) is recorded, not an error.

  • _forecastOnlyForDisplay :: Bool

    internal flag: are forecast transactions being generated only so they can be shown on request (as hledger-ui always does), not because the user asked for them with --forecast ? If so, assert rules ignore them, so they pass or fail as they do without --forecast.

  • _ioDay :: Day

    today's date, for use with forecast transactions XXX this duplicates _rsDay, and should eventually be removed when it's not needed anymore.

  • _oldtimeclock :: Bool

    parse with the old timeclock pairing rules?

  • _journaldir :: Maybe FilePath

    The main journal file's directory. Used eg by the CSV rules reader to locate the journal's data/ directory. Set by the CLI entry points withJournal, withPossibleJournal, and journalReload. If you do a further readJournalFile / readJournalFiles call after a journal has been loaded (eg as import does), apply inputOptsSetJournalDir to its InputOpts so the CSV rules reader can find the right data/. Otherwise, the CSV rules reader falls back to the rules file's own directory.

  • _fileoverrides :: Map FilePath Text

    internal: replacement content for some files, keyed by canonical path (see canonicalizePath), with n line endings. When the reader would read one of these files (as a journal file or an included file), it reads this text instead, and the file need not exist. Used to check a change to a file before writing it (see journalCheckChange in hledger's Hledger.Cli.Utils).

Instances

Instances details
Eq InputOpts Source # 
Instance details

Defined in Hledger.Read.InputOptions

Methods

(==) :: InputOpts -> InputOpts -> Bool

(/=) :: InputOpts -> InputOpts -> Bool

Ord InputOpts Source # 
Instance details

Defined in Hledger.Read.InputOptions

Methods

compare :: InputOpts -> InputOpts -> Ordering

(<) :: InputOpts -> InputOpts -> Bool

(<=) :: InputOpts -> InputOpts -> Bool

(>) :: InputOpts -> InputOpts -> Bool

(>=) :: InputOpts -> InputOpts -> Bool

max :: InputOpts -> InputOpts -> InputOpts

min :: InputOpts -> InputOpts -> InputOpts

Show InputOpts Source # 
Instance details

Defined in Hledger.Read.InputOptions

Methods

showsPrec :: Int -> InputOpts -> ShowS

show :: InputOpts -> String

showList :: [InputOpts] -> ShowS

HasBalancingOpts InputOpts Source # 
Instance details

Defined in Hledger.Read.InputOptions

HasInputOpts InputOpts Source # 
Instance details

Defined in Hledger.Read.InputOptions

Methods

inputOpts :: Lens' InputOpts InputOpts Source #

aliases :: Lens' InputOpts [String] Source #

anon__ :: Lens' InputOpts Bool Source #

auto__ :: Lens' InputOpts Bool Source #

balancingopts :: Lens' InputOpts BalancingOpts Source #

defer :: Lens' InputOpts Bool Source #

dryrun :: Lens' InputOpts Bool Source #

fileoverrides :: Lens' InputOpts (Map FilePath Text) Source #

forecast :: Lens' InputOpts (Maybe DateSpan) Source #

forecastOnlyForDisplay :: Lens' InputOpts Bool Source #

ignore_lots :: Lens' InputOpts Bool Source #

importing :: Lens' InputOpts Bool Source #

infer_costs :: Lens' InputOpts Bool Source #

infer_equity :: Lens' InputOpts Bool Source #

ioDay :: Lens' InputOpts Day Source #

journaldir :: Lens' InputOpts (Maybe FilePath) Source #

mformat :: Lens' InputOpts (Maybe StorageFormat) Source #

mrules_file :: Lens' InputOpts (Maybe FilePath) Source #

new__ :: Lens' InputOpts Bool Source #

new_save :: Lens' InputOpts Bool Source #

oldtimeclock :: Lens' InputOpts Bool Source #

pivot :: Lens' InputOpts String Source #

reportspan :: Lens' InputOpts DateSpan Source #

scanfiles :: Lens' InputOpts Bool Source #

strict :: Lens' InputOpts Bool Source #

verbose_tags :: Lens' InputOpts Bool Source #

class HasInputOpts c where Source #

Minimal complete definition

inputOpts

Methods

inputOpts :: Lens' c InputOpts Source #

aliases :: Lens' c [String] Source #

anon__ :: Lens' c Bool Source #

auto__ :: Lens' c Bool Source #

balancingopts :: Lens' c BalancingOpts Source #

defer :: Lens' c Bool Source #

dryrun :: Lens' c Bool Source #

fileoverrides :: Lens' c (Map FilePath Text) Source #

forecast :: Lens' c (Maybe DateSpan) Source #

forecastOnlyForDisplay :: Lens' c Bool Source #

ignore_lots :: Lens' c Bool Source #

importing :: Lens' c Bool Source #

infer_costs :: Lens' c Bool Source #

infer_equity :: Lens' c Bool Source #

ioDay :: Lens' c Day Source #

journaldir :: Lens' c (Maybe FilePath) Source #

mformat :: Lens' c (Maybe StorageFormat) Source #

mrules_file :: Lens' c (Maybe FilePath) Source #

new__ :: Lens' c Bool Source #

new_save :: Lens' c Bool Source #

oldtimeclock :: Lens' c Bool Source #

pivot :: Lens' c String Source #

reportspan :: Lens' c DateSpan Source #

scanfiles :: Lens' c Bool Source #

strict :: Lens' c Bool Source #

verbose_tags :: Lens' c Bool Source #

Instances

Instances details
HasInputOpts InputOpts Source # 
Instance details

Defined in Hledger.Read.InputOptions

Methods

inputOpts :: Lens' InputOpts InputOpts Source #

aliases :: Lens' InputOpts [String] Source #

anon__ :: Lens' InputOpts Bool Source #

auto__ :: Lens' InputOpts Bool Source #

balancingopts :: Lens' InputOpts BalancingOpts Source #

defer :: Lens' InputOpts Bool Source #

dryrun :: Lens' InputOpts Bool Source #

fileoverrides :: Lens' InputOpts (Map FilePath Text) Source #

forecast :: Lens' InputOpts (Maybe DateSpan) Source #

forecastOnlyForDisplay :: Lens' InputOpts Bool Source #

ignore_lots :: Lens' InputOpts Bool Source #

importing :: Lens' InputOpts Bool Source #

infer_costs :: Lens' InputOpts Bool Source #

infer_equity :: Lens' InputOpts Bool Source #

ioDay :: Lens' InputOpts Day Source #

journaldir :: Lens' InputOpts (Maybe FilePath) Source #

mformat :: Lens' InputOpts (Maybe StorageFormat) Source #

mrules_file :: Lens' InputOpts (Maybe FilePath) Source #

new__ :: Lens' InputOpts Bool Source #

new_save :: Lens' InputOpts Bool Source #

oldtimeclock :: Lens' InputOpts Bool Source #

pivot :: Lens' InputOpts String Source #

reportspan :: Lens' InputOpts DateSpan Source #

scanfiles :: Lens' InputOpts Bool Source #

strict :: Lens' InputOpts Bool Source #

verbose_tags :: Lens' InputOpts Bool Source #

fileOverride :: InputOpts -> FilePath -> IO (Maybe Text) Source #

The replacement content for this file in the input options' _fileoverrides, if any. Standard input ("-") is never overridden. Paths are compared canonically, which is skipped when there are no overrides (the usual case).

inputOptsSetJournalDir :: Journal -> InputOpts -> InputOpts Source #

Set _journaldir from a parsed Journal (using takeDirectory . journalFilePath).

Use this when you want to do a further readJournalFile / readJournalFiles call after a journal has been loaded — eg the hledger import command reads the user's rules files in a second pass — so the CSV rules reader can find the journal's data/ directory for source lookups and archive saves. Otherwise it will fall back to using the rules file's own directory, which is no longer the preferred place.

Usage:

iopts' = inputOptsSetJournalDir j $ iopts { ...other tweaks... }

forecastPeriod :: InputOpts -> Journal -> Maybe DateSpan Source #

Get the Maybe the DateSpan to generate forecast options from. This begins on: - the start date supplied to the `--forecast` argument, if present - otherwise, the later of - the report start date if specified with -b-pdate: - the day after the latest normal (non-periodic) transaction in the journal, if any - otherwise today. It ends on: - the end date supplied to the `--forecast` argument, if present - otherwise the report end date if specified with -e-pdate: - otherwise 180 days (6 months) from today.