-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Command-line interface for the hledger accounting system -- -- The command-line interface for the hledger accounting system. Its -- basic function is to read a plain text file describing financial -- transactions and produce useful reports. -- -- hledger is a robust, cross-platform set of tools for tracking money, -- time, or any other commodity, using double-entry accounting and a -- simple, editable file format, with command-line, terminal and web -- interfaces. It is a Haskell rewrite of Ledger, and one of the leading -- implementations of Plain Text Accounting. Read more at: -- https://hledger.org @package hledger @version 1.21 -- | Instances for anonymizing sensitive data in various types. -- -- Note that there is no clear way to anonymize numbers. module Hledger.Cli.Anon class Anon a -- | Consistent converter to structure with sensitive data anonymized anon :: Anon a => a -> a -- | Anonymize account name preserving hierarchy anonAccount :: AccountName -> AccountName instance Hledger.Cli.Anon.Anon Hledger.Data.Types.Journal instance Hledger.Cli.Anon.Anon Hledger.Data.Types.Posting instance Hledger.Cli.Anon.Anon Hledger.Data.Types.Transaction instance Hledger.Cli.Anon.Anon Data.Text.Internal.Text module Hledger.Cli.Commands.Check.Uniqueleafnames -- | Check that all the journal's postings are to accounts with a unique -- leaf name. Otherwise, return an error message for the first offending -- posting. journalCheckUniqueleafnames :: Journal -> Either String () -- | Embedded documentation files in various formats, and helpers for -- viewing them. -- -- | module Hledger.Cli.DocFiles type Topic = String -- | Print plain text help for this tool. Takes an optional topic argument -- for convenience but it is currently ignored. printHelpForTopic :: Tool -> Maybe Topic -> IO () -- | Display a man page for this tool, scrolled to the given topic if -- provided, using the "man" executable in $PATH. Note when a topic is -- provided we force man to use the "less" executable in $PATH, ignoring -- $MANPAGER and $PAGER. runManForTopic :: Tool -> Maybe Topic -> IO () -- | Display an info manual for this topic, opened at the given topic if -- provided, using the "info" executable in $PATH. runInfoForTopic :: Tool -> Maybe Topic -> IO () -- | Display plain text help for this tool, scrolled to the given topic if -- provided, using the given pager executable. Note when a topic is -- provided we ignore the provided pager and use the "less" executable in -- $PATH. runPagerForTopic :: Tool -> Maybe Topic -> IO () module Hledger.Cli.Version progname :: String version :: String prognameandversion :: String prognameanddetailedversion :: String -- | Given a program name, return a precise platform-specific executable -- name suitable for naming downloadable binaries. Can raise an error if -- the version and patch level was not defined correctly at build time. binaryfilename :: String -> String -- | Common cmdargs modes and flags, a command-line options type, and -- related utilities used by hledger commands. module Hledger.Cli.CliOptions -- | Common help flags: --help, --debug, --version... helpflags :: [Flag RawOpts] -- | A hidden flag just for the hledger executable. detailedversionflag :: Flag RawOpts -- | Flags for selecting flat/tree mode, used for reports organised by -- account. With a True argument, shows some extra help about -- inclusive/exclusive amounts. flattreeflags :: Bool -> [Flag RawOpts] -- | Common flags that are accepted but not shown in --help, such as -- --effective, --aux-date. hiddenflags :: [Flag RawOpts] -- | Common input-related flags: --file, --rules-file, --alias... inputflags :: [Flag RawOpts] -- | Common report-related flags: --period, --cost, etc. reportflags :: [Flag RawOpts] -- | Common output-related flags: --output-file, --output-format... outputFormatFlag :: [String] -> Flag RawOpts outputFileFlag :: Flag RawOpts generalflagsgroup1 :: (String, [Flag RawOpts]) generalflagsgroup2 :: (String, [Flag RawOpts]) generalflagsgroup3 :: (String, [Flag RawOpts]) -- | An empty cmdargs mode to use as a template. Modes describe the -- top-level command, ie the program, or a subcommand, telling cmdargs -- how to parse a command line and how to generate the command's usage -- text. defMode :: Mode RawOpts -- | A cmdargs mode suitable for a hledger built-in command with the given -- names (primary name + optional aliases). The usage message shows -- [QUERY] as argument. defCommandMode :: [Name] -> Mode RawOpts -- | A cmdargs mode representing the hledger add-on command with the given -- name, providing hledger's common inputreportinghelp flags. Just -- used when invoking addons. addonCommandMode :: Name -> Mode RawOpts -- | Build a cmdarg mode for a hledger command, from a help template and -- flag/argument specifications. Reduces boilerplate a little, though the -- complicated cmdargs flag and argument specs are still required. hledgerCommandMode :: CommandDoc -> [Flag RawOpts] -> [(String, [Flag RawOpts])] -> [Flag RawOpts] -> ([Arg RawOpts], Maybe (Arg RawOpts)) -> Mode RawOpts argsFlag :: FlagHelp -> Arg RawOpts -- | Get a mode's usage message as a nicely wrapped string. showModeUsage :: Mode a -> String -- | Add command aliases to the command's help string. withAliases :: String -> [String] -> String -- | Get all sorted unique filenames in the current user's PATH. We do not -- currently filter out non-file objects or files without execute -- permission. likelyExecutablesInPath :: IO [String] -- | Get the sorted unique filenames of all hledger-* executables in the -- current user's PATH. These are files in any of the PATH directories, -- named hledger-*, with either no extension (and no periods in the name) -- or one of the addonExtensions. We do not currently filter out non-file -- objects or files without execute permission. hledgerExecutablesInPath :: IO [String] -- | Command line options, used in the hledger package and above. -- This is the "opts" used throughout hledger CLI code. representing the -- options and arguments that were provided at startup on the -- command-line. data CliOpts CliOpts :: RawOpts -> String -> [FilePath] -> InputOpts -> ReportSpec -> Maybe FilePath -> Maybe String -> Int -> Bool -> Maybe String -> Int -> CliOpts [rawopts_] :: CliOpts -> RawOpts [command_] :: CliOpts -> String [file_] :: CliOpts -> [FilePath] [inputopts_] :: CliOpts -> InputOpts [reportspec_] :: CliOpts -> ReportSpec [output_file_] :: CliOpts -> Maybe FilePath [output_format_] :: CliOpts -> Maybe String -- | debug level, set by --debug[=N]. See also debugLevel. [debug_] :: CliOpts -> Int [no_new_accounts_] :: CliOpts -> Bool -- | the --width value provided, if any [width_] :: CliOpts -> Maybe String -- | estimated usable screen width, based on 1. the COLUMNS env var, if set -- 2. the width reported by the terminal, if supported 3. the default -- (80) [available_width_] :: CliOpts -> Int defcliopts :: CliOpts getHledgerCliOpts :: Mode RawOpts -> IO CliOpts -- | A helper for addon commands: this parses options and arguments from -- the current command line using the given hledger-style cmdargs mode, -- and returns a CliOpts. Or, with --help or -h present, it prints long -- or short help, and exits the program. When --debug is present, also -- prints some debug output. Note this is not used by the main hledger -- executable. -- -- The help texts are generated from the mode. Long help includes the -- full usage description generated by cmdargs (including all supported -- options), framed by whatever pre- and postamble text the mode -- specifies. It's intended that this forms a complete help document or -- manual. -- -- Short help is a truncated version of the above: the preamble and the -- first part of the usage, up to the first line containing "flags:" -- (normally this marks the start of the common hledger flags); plus a -- mention of --help and the (presumed supported) common hledger options -- not displayed. -- -- Tips: Empty lines in the pre/postamble are removed by cmdargs; add a -- space character to preserve them. getHledgerCliOpts' :: Mode RawOpts -> [String] -> IO CliOpts -- | Parse raw option string values to the desired final data types. Any -- relative smart dates will be converted to fixed dates based on today's -- date. Parsing failures will raise an error. Also records the terminal -- width, if supported. rawOptsToCliOpts :: RawOpts -> IO CliOpts outputFormats :: [String] defaultOutputFormat :: String -- | A command's documentation. Used both as part of CLI help, and as part -- of the hledger manual. See parseCommandDoc. type CommandDoc = String -- | Get the (tilde-expanded, absolute) journal file path from 1. options, -- 2. an environment variable, or 3. the default. Actually, returns one -- or more file paths. There will be more than one if multiple -f options -- were provided. File paths can have a READER: prefix naming a -- reader/data format. journalFilePathFromOpts :: CliOpts -> IO [String] -- | Get the (tilde-expanded) rules file path from options, if any. rulesFilePathFromOpts :: CliOpts -> IO (Maybe FilePath) -- | Get the expanded, absolute output file path from options, or the -- default (-, meaning stdout). outputFileFromOpts :: CliOpts -> IO FilePath -- | Get the output format from the --output-format option, otherwise from -- a recognised file extension in the --output-file option, otherwise the -- default (txt). outputFormatFromOpts :: CliOpts -> String -- | Default width for hledger console output, when not otherwise -- specified. defaultWidth :: Int -- | Get the width in characters to use for console output. This comes from -- the --width option, or the COLUMNS environment variable, or (on posix -- platforms) the current terminal width, or 80. Will raise a parse error -- for a malformed --width argument. widthFromOpts :: CliOpts -> Int -- | Replace any numeric flags (eg -2) with their long form (--depth 2), as -- I'm guessing cmdargs doesn't support this directly. replaceNumericFlags :: [String] -> [String] -- | Get the width in characters to use for the register command's console -- output, and also the description column width if specified (following -- the main width, comma-separated). The widths will be as follows: -- no --width flag - overall width is the available width (COLUMNS, or -- posix terminal width, or 80); description width is unspecified (auto) -- --width W - overall width is W, description width is auto --width W,D -- - overall width is W, description width is D Will raise a parse -- error for a malformed --width argument. registerWidthsFromOpts :: CliOpts -> (Int, Maybe Int) -- | Get the sorted unique canonical names of hledger addon commands found -- in the current user's PATH. These are used in command line parsing and -- to display the commands list. -- -- Canonical addon names are the filenames of hledger-* executables in -- PATH, without the "hledger-" prefix, and without the file extension -- except when it's needed for disambiguation (see below). -- -- When there are exactly two versions of an executable (same base name, -- different extensions) that look like a source and compiled pair (one -- has .exe, .com, or no extension), the source version will be excluded -- (even if it happens to be newer). When there are three or more -- versions (or two versions that don't look like a source/compiled -- pair), they are all included, with file extensions intact. hledgerAddons :: IO [String] -- | Get the most appropriate documentation topic for a mode. Currently, -- that is either the hledger, hledger-ui or hledger-web manual. topicForMode :: Mode a -> Topic instance GHC.Show.Show Hledger.Cli.CliOptions.CliOpts instance Data.Default.Class.Default Hledger.Cli.CliOptions.CliOpts -- | Utilities for top-level modules and ghci. See also Hledger.Read and -- Hledger.Utils. module Hledger.Cli.Utils -- | Standard error message for a bad output format specified with -O/-o. unsupportedOutputFormatError :: String -> String -- | 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. withJournalDo :: CliOpts -> (Journal -> IO a) -> IO a -- | Write some output to stdout or to a file selected by --output-file. If -- the file exists it will be overwritten. writeOutput :: CliOpts -> String -> IO () -- | Write some output to stdout or to a file selected by --output-file. If -- the file exists it will be overwritten. This function operates on Lazy -- Text values. writeOutputLazyText :: CliOpts -> Text -> IO () -- | Apply some extra post-parse transformations to the journal, if -- specified by options. These happen after journal validation, but -- before report calculation. They include: -- -- journalTransform :: CliOpts -> Journal -> Journal -- | 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). -- -- When --auto is active, auto posting rules will be applied to the -- generated transactions. If the query in any auto posting rule fails to -- parse, this function will raise an error. -- -- The start & end date for generated periodic transactions are -- determined in a somewhat complicated way; see the hledger manual -> -- Periodic transactions. journalAddForecast :: CliOpts -> Journal -> Journal -- | 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. journalReload :: CliOpts -> IO (Either String Journal) -- | 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. journalReloadIfChanged :: CliOpts -> Day -> Journal -> IO (Either String Journal, Bool) -- | Has the specified file changed since the journal was last read ? -- Typically this is one of the journal's journalFilePaths. These are not -- always real files, so the file's existence is tested first; for -- non-files the answer is always no. journalFileIsNewer :: Journal -> FilePath -> IO Bool -- | Attempt to open a web browser on the given url, all platforms. openBrowserOn :: String -> IO ExitCode -- | Back up this file with a (incrementing) numbered suffix, then -- overwrite it with this new text, or give an error. writeFileWithBackup :: FilePath -> String -> IO () -- | 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. -- -- The given text should have unix line endings (n); the existing file -- content will be normalised to unix line endings before comparing the -- two. If the file is overwritten, the new file will have the current -- system's native line endings (n on unix, rn on windows). This could be -- different from the file's previous line endings, if working with a DOS -- file on unix or vice-versa. writeFileWithBackupIfChanged :: FilePath -> Text -> IO Bool readFileStrictly :: FilePath -> IO Text -- | Apply the pivot transformation on a journal, if option is present. pivotByOpts :: CliOpts -> Journal -> Journal -- | Apply the anonymisation transformation on a journal, if option is -- present anonymiseByOpts :: CliOpts -> Journal -> Journal utcTimeToClockTime :: UTCTime -> ClockTime journalSimilarTransaction :: CliOpts -> Journal -> Text -> Maybe Transaction tests_Cli_Utils :: TestTree module Hledger.Cli.Commands.Tags tagsmode :: Mode RawOpts tags :: CliOpts -> Journal -> IO () -- | Print some statistics for the journal. module Hledger.Cli.Commands.Stats statsmode :: Mode RawOpts -- | Print various statistics for the journal. stats :: CliOpts -> Journal -> IO () -- | The roi command prints internal rate of return and -- time-weighted rate of return for and investment. module Hledger.Cli.Commands.Roi roimode :: Mode RawOpts roi :: CliOpts -> Journal -> IO () instance GHC.Show.Show Hledger.Cli.Commands.Roi.OneSpan -- | A ledger-compatible register command. module Hledger.Cli.Commands.Register registermode :: Mode RawOpts -- | Print a (posting) register report. register :: CliOpts -> Journal -> IO () -- | Render a register report as plain text suitable for console output. postingsReportAsText :: CliOpts -> PostingsReport -> Text -- | Render one register report line item as plain text. Layout is like so: -- width (specified, terminal width, or 80) -- -------------------- date (10) description account amount (12) -- balance (12) DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa -- AAAAAAAAAAAA AAAAAAAAAAAA If description's width is specified, -- account will use the remaining space. Otherwise, description and -- account divide up the space equally. -- -- With a report interval, the layout is like so: width -- (specified, terminal width, or 80) -------------------- date (21) -- account amount (12) balance (12) DDDDDDDDDDDDDDDDDDDDD -- aaaaaaaaaaaaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA -- -- date and description are shown for the first posting of a transaction -- only. -- -- Returns a string which can be multi-line, eg if the running balance -- has multiple commodities. Does not yet support formatting control like -- balance reports. postingsReportItemAsText :: CliOpts -> Int -> Int -> PostingsReportItem -> Builder tests_Register :: TestTree module Hledger.Cli.Commands.Registermatch registermatchmode :: Mode RawOpts registermatch :: CliOpts -> Journal -> IO () -- | A ledger-compatible print command. module Hledger.Cli.Commands.Print printmode :: Mode RawOpts -- | Print journal transactions in standard format. print' :: CliOpts -> Journal -> IO () originalTransaction :: Transaction -> Transaction module Hledger.Cli.Commands.Rewrite rewritemode :: Mode RawOpts rewrite :: CliOpts -> Journal -> IO () instance Data.Traversable.Traversable Hledger.Cli.Commands.Rewrite.DiffLine instance Data.Foldable.Foldable Hledger.Cli.Commands.Rewrite.DiffLine instance GHC.Base.Functor Hledger.Cli.Commands.Rewrite.DiffLine instance GHC.Show.Show a => GHC.Show.Show (Hledger.Cli.Commands.Rewrite.DiffLine a) module Hledger.Cli.Commands.Printunique printuniquemode :: Mode RawOpts printunique :: CliOpts -> Journal -> IO () module Hledger.Cli.Commands.Prices pricesmode :: Mode RawOpts prices :: CliOpts -> Journal -> IO () -- | The payees command lists all unique payees (description part -- before a |) seen in transactions, sorted alphabetically. module Hledger.Cli.Commands.Payees -- | Command line options for this command. payeesmode :: Mode RawOpts -- | The payees command. payees :: CliOpts -> Journal -> IO () -- | The notes command lists all unique notes (description part -- after a |) seen in transactions, sorted alphabetically. module Hledger.Cli.Commands.Notes -- | Command line options for this command. notesmode :: Mode RawOpts -- | The notes command. notes :: CliOpts -> Journal -> IO () -- | The help command. -- -- | module Hledger.Cli.Commands.Help helpmode :: Mode RawOpts -- | Display the hledger manual in various formats. You can select a docs -- viewer with one of the `--info`, `--man`, `--pager` flags. Otherwise -- it will use the first available of: info, man, $PAGER, less, stdout -- (and always stdout if output is non-interactive). help' :: CliOpts -> Journal -> IO () -- | The files command lists included files. module Hledger.Cli.Commands.Files -- | Command line options for this command. filesmode :: Mode RawOpts -- | The files command. files :: CliOpts -> Journal -> IO () -- | The diff command compares two diff. module Hledger.Cli.Commands.Diff -- | Command line options for this command. diffmode :: Mode RawOpts -- | The diff command. diff :: CliOpts -> Journal -> IO () instance GHC.Show.Show Hledger.Cli.Commands.Diff.PostingWithPath instance GHC.Classes.Eq Hledger.Cli.Commands.Diff.PostingWithPath -- | The descriptions command lists all unique descriptions seen -- in transactions, sorted alphabetically. module Hledger.Cli.Commands.Descriptions -- | Command line options for this command. descriptionsmode :: Mode RawOpts -- | The descriptions command. descriptions :: CliOpts -> Journal -> IO () -- | The commodities command lists commodity/currency symbols. module Hledger.Cli.Commands.Commodities -- | Command line options for this command. commoditiesmode :: Mode RawOpts commodities :: CliOpts -> Journal -> IO () -- | The codes command lists the codes seen in transactions, in -- the order parsed. module Hledger.Cli.Commands.Codes -- | Command line options for this command. codesmode :: Mode RawOpts -- | The codes command. codes :: CliOpts -> Journal -> IO () module Hledger.Cli.Commands.Close closemode :: Mode RawOpts close :: CliOpts -> Journal -> IO () module Hledger.Cli.Commands.Check.Ordereddates journalCheckOrdereddates :: CliOpts -> Journal -> Either String () module Hledger.Cli.Commands.Check checkmode :: Mode RawOpts check :: CliOpts -> Journal -> IO () instance GHC.Enum.Bounded Hledger.Cli.Commands.Check.Check instance GHC.Enum.Enum Hledger.Cli.Commands.Check.Check instance GHC.Classes.Eq Hledger.Cli.Commands.Check.Check instance GHC.Show.Show Hledger.Cli.Commands.Check.Check instance GHC.Read.Read Hledger.Cli.Commands.Check.Check -- | A ledger-compatible balance command, with additional support -- for multi-column reports. -- -- Here is a description/specification for the balance command. See also -- Hledger.Reports -> "Balance reports". -- -- Basic balance report -- -- With no report interval (--monthly etc.), hledger's balance -- command emulates ledger's, showing accounts indented according to -- hierarchy, along with their total amount posted (including -- subaccounts). -- -- Here's an example. With examples/sample.journal, which -- defines the following account tree: -- --
--   assets
--     bank
--       checking
--       saving
--     cash
--   expenses
--     food
--     supplies
--   income
--     gifts
--     salary
--   liabilities
--     debts
--   
-- -- the basic balance command gives this output: -- --
--    $ hledger -f sample.journal balance
--                    $-1  assets
--                     $1    bank:saving
--                    $-2    cash
--                     $2  expenses
--                     $1    food
--                     $1    supplies
--                    $-2  income
--                    $-1    gifts
--                    $-1    salary
--                     $1  liabilities:debts
--   --------------------
--                      0
--   
-- -- Subaccounts are displayed indented below their parent. Only the -- account leaf name (the final part) is shown. (With --flat, -- account names are shown in full and unindented.) -- -- Each account's "balance" is the sum of postings in that account and -- any subaccounts during the report period. When the report period -- includes all transactions, this is equivalent to the account's current -- balance. -- -- The overall total of the highest-level displayed accounts is shown -- below the line. (The --no-total/-N flag prevents this.) -- -- Eliding and omitting -- -- Accounts which have a zero balance, and no non-zero subaccount -- balances, are normally omitted from the report. (The -- --empty/-E flag forces such accounts to be displayed.) Eg, -- above checking is omitted because it has a zero balance and -- no subaccounts. -- -- Accounts which have a single subaccount also being displayed, with the -- same balance, are normally elided into the subaccount's line. (The -- --no-elide flag prevents this.) Eg, above bank is -- elided to bank:saving because it has only a single displayed -- subaccount (saving) and their balance is the same ($1). -- Similarly, liabilities is elided to -- liabilities:debts. -- -- Date limiting -- -- The default report period is that of the whole journal, including all -- known transactions. The --begin/-b, --end/-e, -- --period/-p options or date:/date2: -- patterns can be used to report only on transactions before and/or -- after specified dates. -- -- Depth limiting -- -- The --depth option can be used to limit the depth of the -- balance report. Eg, to see just the top level accounts (still -- including their subaccount balances): -- --
--   $ hledger -f sample.journal balance --depth 1
--                    $-1  assets
--                     $2  expenses
--                    $-2  income
--                     $1  liabilities
--   --------------------
--                      0
--   
-- -- Account limiting -- -- With one or more account pattern arguments, the report is restricted -- to accounts whose name matches one of the patterns, plus their parents -- and subaccounts. Eg, adding the pattern o to the first -- example gives: -- --
--    $ hledger -f sample.journal balance o
--                     $1  expenses:food
--                    $-2  income
--                    $-1    gifts
--                    $-1    salary
--   --------------------
--                    $-1
--   
-- -- -- -- Multi-column balance report -- -- hledger's balance command will show multiple columns when a reporting -- interval is specified (eg with --monthly), one column for -- each sub-period. -- -- There are three accumulation strategies for multi-column balance -- report, indicated by the heading: -- -- -- --
--   Change of balance (flow):
--   
--                    Jan   Feb   Mar
--   assets:checking   20    10    -5
--   
-- -- -- --
--   Ending balance (cumulative):
--   
--                    Jan   Feb   Mar
--   assets:checking   20    30    25
--   
-- -- -- --
--   Ending balance (historical):
--   
--                    Jan   Feb   Mar
--   assets:checking  120   130   125
--   
-- -- Eliding and omitting, 2 -- -- Here's a (imperfect?) specification for the eliding/omitting -- behaviour: -- -- -- -- Which accounts to show in balance reports -- -- By default: -- -- -- -- With -E/--empty: -- -- -- -- Which periods (columns) to show in balance reports -- -- An empty period/column is one where no report account has any -- postings. A zero period/column is one where no report account has a -- non-zero period balance. -- -- Currently, -- -- by default: -- -- -- -- With -E/--empty: -- -- -- -- What to show in empty cells -- -- An empty periodic balance report cell is one which has no -- corresponding postings. An empty cumulative/historical balance report -- cell is one which has no corresponding or prior postings, ie the -- account doesn't exist yet. Currently, empty cells show 0. module Hledger.Cli.Commands.Balance -- | Command line options for this command. balancemode :: Mode RawOpts -- | The balance command, prints a balance report. balance :: CliOpts -> Journal -> IO () -- | Render a single-column balance report as plain text. balanceReportAsText :: ReportOpts -> BalanceReport -> Builder -- | Render one balance report line item as plain text suitable for console -- output (or whatever string format is specified). Note, prices will not -- be rendered, and differently-priced quantities of the same commodity -- will appear merged. The output will be one or more lines depending on -- the format and number of commodities. balanceReportItemAsText :: ReportOpts -> BalanceReportItem -> (Builder, [Int]) -- | Render a multi-column balance report as plain text suitable for -- console output. multiBalanceReportAsText :: ReportOpts -> MultiBalanceReport -> Text -- | Render a multi-column balance report as CSV. The CSV will always -- include the initial headings row, and will include the final totals -- row unless --no-total is set. multiBalanceReportAsCsv :: ReportOpts -> MultiBalanceReport -> CSV -- | Render a multi-column balance report as HTML. multiBalanceReportAsHtml :: ReportOpts -> MultiBalanceReport -> Html () -- | Render the HTML table rows for a MultiBalanceReport. Returns the -- heading row, 0 or more body rows, and the totals row if enabled. multiBalanceReportHtmlRows :: ReportOpts -> MultiBalanceReport -> (Html (), [Html ()], Maybe (Html ())) -- | Build a Table from a multi-column balance report. balanceReportAsTable :: ReportOpts -> MultiBalanceReport -> Table Text Text MixedAmount -- | Given a table representing a multi-column balance report (for example, -- made using balanceReportAsTable), render it in a format -- suitable for console output. Amounts with more than two commodities -- will be elided unless --no-elide is used. balanceReportTableAsText :: ReportOpts -> Table Text Text MixedAmount -> Builder tests_Balance :: TestTree -- | Common helpers for making multi-section balance report commands like -- balancesheet, cashflow, and incomestatement. module Hledger.Cli.CompoundBalanceCommand -- | Description of a compound balance report command, from which we -- generate the command's cmdargs mode and IO action. A compound balance -- report command shows one or more sections/subreports, each with its -- own title and subtotals row, in a certain order, plus a grand totals -- row if there's more than one section. Examples are the balancesheet, -- cashflow and incomestatement commands. -- -- Compound balance reports do sign normalisation: they show all account -- balances as normally positive, unlike the ordinary BalanceReport and -- most hledger commands which show incomeliabilityequity balances -- as normally negative. Each subreport specifies the normal sign of its -- amounts, and whether it should be added to or subtracted from the -- grand total. data CompoundBalanceCommandSpec CompoundBalanceCommandSpec :: CommandDoc -> String -> [CBCSubreportSpec DisplayName] -> BalanceType -> CompoundBalanceCommandSpec -- | the command's name(s) and documentation [cbcdoc] :: CompoundBalanceCommandSpec -> CommandDoc -- | overall report title [cbctitle] :: CompoundBalanceCommandSpec -> String -- | subreport details [cbcqueries] :: CompoundBalanceCommandSpec -> [CBCSubreportSpec DisplayName] -- | the "balance" type (change, cumulative, historical) this report shows -- (overrides command line flags) [cbctype] :: CompoundBalanceCommandSpec -> BalanceType -- | Generate a cmdargs option-parsing mode from a compound balance command -- specification. compoundBalanceCommandMode :: CompoundBalanceCommandSpec -> Mode RawOpts -- | Generate a runnable command from a compound balance command -- specification. compoundBalanceCommand :: CompoundBalanceCommandSpec -> CliOpts -> Journal -> IO () -- | The incomestatement command prints a simple income statement -- (profit & loss report). module Hledger.Cli.Commands.Incomestatement incomestatementmode :: Mode RawOpts incomestatement :: CliOpts -> Journal -> IO () -- | The cashflow command prints a simplified cashflow statement. -- It just shows the change in all "cash" accounts for the period -- (without the traditional segmentation into operating, investing, and -- financing cash flows.) module Hledger.Cli.Commands.Cashflow cashflowmode :: Mode RawOpts cashflow :: CliOpts -> Journal -> IO () -- | The balancesheetequity command prints a simple balance sheet. module Hledger.Cli.Commands.Balancesheetequity balancesheetequitymode :: Mode RawOpts balancesheetequity :: CliOpts -> Journal -> IO () -- | The balancesheet command prints a simple balance sheet. module Hledger.Cli.Commands.Balancesheet balancesheetmode :: Mode RawOpts balancesheet :: CliOpts -> Journal -> IO () -- | The aregister command lists a single account's transactions, -- like the account register in hledger-ui and hledger-web, and unlike -- the register command which lists postings across multiple accounts. module Hledger.Cli.Commands.Aregister aregistermode :: Mode RawOpts -- | Print an account register report for a specified account. aregister :: CliOpts -> Journal -> IO () tests_Aregister :: TestTree -- | A history-aware add command to help with data entry. | module Hledger.Cli.Commands.Add addmode :: Mode RawOpts -- | 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. add :: CliOpts -> Journal -> IO () -- | 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. -- -- XXX This writes unix line endings (n), some at least, even if the file -- uses dos line endings (rn), which could leave mixed line endings in -- the file. See also writeFileWithBackupIfChanged. appendToJournalFileOrStdout :: FilePath -> Text -> IO () -- | Append this transaction to the journal's file and transaction list. journalAddTransaction :: Journal -> CliOpts -> Transaction -> IO Journal instance GHC.Show.Show Hledger.Cli.Commands.Add.EntryState instance GHC.Show.Show Hledger.Cli.Commands.Add.RestartTransactionException instance GHC.Show.Show Hledger.Cli.Commands.Add.TxnParams instance GHC.Show.Show Hledger.Cli.Commands.Add.PrevInput instance GHC.Exception.Type.Exception Hledger.Cli.Commands.Add.RestartTransactionException module Hledger.Cli.Commands.Import importmode :: Mode RawOpts importcmd :: CliOpts -> Journal -> IO () -- | Print a bar chart of posting activity per day, or other report -- interval. module Hledger.Cli.Commands.Activity activitymode :: Mode RawOpts barchar :: Char -- | Print a bar chart of number of postings per report interval. activity :: CliOpts -> Journal -> IO () showHistogram :: ReportSpec -> Journal -> String printDayWith :: (PrintfArg t1, PrintfType t2) => (t3 -> t1) -> (DateSpan, t3) -> t2 countBar :: Foldable t => t a -> [Char] -- | The accounts command lists account names: -- -- module Hledger.Cli.Commands.Accounts -- | Command line options for this command. accountsmode :: Mode RawOpts -- | The accounts command. accounts :: CliOpts -> Journal -> IO () -- | hledger's built-in commands, and helpers for printing the commands -- list. -- -- New built-in commands should be added in four places below: the export -- list, the import list, builtinCommands, commandsList. module Hledger.Cli.Commands -- | Look up a builtin command's mode and action by exact command name or -- alias. findCommand :: String -> Maybe (Mode RawOpts, CliOpts -> Journal -> IO ()) -- | The test command, which runs the hledger and hledger-lib packages' -- unit tests. This command also accepts tasty test runner options, -- written after a -- (double hyphen). -- -- Unlike most hledger commands, this one does not read the user's -- journal. A Journal argument remains in the type signature, but -- it should not be used (and would raise an error). testcmd :: CliOpts -> Journal -> IO () -- | The cmdargs subcommand mode (for command-line parsing) and IO action -- (for doing the command's work) for each builtin command. Command -- actions take parsed CLI options and a (lazy) finalised journal. builtinCommands :: [(Mode RawOpts, CliOpts -> Journal -> IO ())] -- | All names and aliases of builtin commands. builtinCommandNames :: [String] -- | Print the commands list, modifying the template above based on the -- currently available addons. Missing addons will be removed, and extra -- addons will be added under Misc. printCommandsList :: [String] -> IO () tests_Hledger_Cli :: TestTree -- | Hledger.Cli re-exports the options, utilities and commands provided by -- the hledger command-line program. This module also aggregates the -- built-in unit tests defined throughout hledger and hledger-lib, and -- adds some more which are easier to define here. module Hledger.Cli -- | Create verbosity flags triggered by -v/--verbose and -- -q/--quiet flagsVerbosity :: (Verbosity -> a -> a) -> [Flag a] -- | Create a version flag triggered by --numeric-version. flagNumericVersion :: (a -> a) -> Flag a -- | Create a version flag triggered by -V/--version. flagVersion :: (a -> a) -> Flag a -- | Create a help flag triggered by -?/--help. The user -- may optionally modify help by specifying the format, such as: -- --
--   --help=all          - help for all modes
--   --help=html         - help in HTML format
--   --help=100          - wrap the text at 100 characters
--   --help=100,one      - full text wrapped at 100 characters
--   
flagHelpFormat :: (HelpFormat -> TextFormat -> a -> a) -> Flag a -- | Create a help flag triggered by -?/--help. flagHelpSimple :: (a -> a) -> Flag a -- | Like processValue but on failure prints to stderr and exits the -- program. processValueIO :: Mode a -> [String] -> IO a -- | Process a list of flags (usually obtained from getArgs -- and expandArgsAt) with a mode. Throws an error if the -- command line fails to parse, or returns the associated value. -- Implemeneted in terms of process. This function does not take -- account of any environment variables that may be set (see -- processArgs). -- -- If you are in IO you will probably get a better user experience -- by calling processValueIO. processValue :: Mode a -> [String] -> a -- | Process the flags obtained by getArgs and -- expandArgsAt with a mode. Displays an error and exits -- with failure if the command line fails to parse, or returns the -- associated value. Implemented in terms of process. This -- function makes use of the following environment variables: -- -- processArgs :: Mode a -> IO a -- | Generate a help message from a mode. The first argument is a prefix, -- which is prepended when not using HelpFormatBash or -- HelpFormatZsh. helpText :: [String] -> HelpFormat -> Mode a -> [Text] -- | Specify the format to output the help. data HelpFormat -- | Equivalent to HelpFormatAll if there is not too much text, -- otherwise HelpFormatOne. HelpFormatDefault :: HelpFormat -- | Display only the first mode. HelpFormatOne :: HelpFormat -- | Display all modes. HelpFormatAll :: HelpFormat -- | Bash completion information HelpFormatBash :: HelpFormat -- | Z shell completion information HelpFormatZsh :: HelpFormat -- | Given a current state, return the set of commands you could type now, -- in preference order. complete :: Mode a -> [String] -> (Int, Int) -> [Complete] -- | How to complete a command line option. The Show instance is -- suitable for parsing from shell scripts. data Complete -- | Complete to a particular value CompleteValue :: String -> Complete -- | Complete to a prefix, and a file CompleteFile :: String -> FilePath -> Complete -- | Complete to a prefix, and a directory CompleteDir :: String -> FilePath -> Complete -- | Process a list of flags (usually obtained from -- getArgs/expandArgsAt) with a mode. Returns -- Left and an error message if the command line fails to parse, -- or Right and the associated value. process :: Mode a -> [String] -> Either String a -- | Create a boolean flag, with a list of flag names, an update function -- and some help text. flagBool :: [Name] -> (Bool -> a -> a) -> Help -> Flag a -- | Create an argument flag, with an update function and the type of the -- argument. flagArg :: Update a -> FlagHelp -> Arg a -- | Create a flag taking a required argument value, with a list of flag -- names, an update function, the type of the argument and some help -- text. flagReq :: [Name] -> Update a -> FlagHelp -> Help -> Flag a -- | Create a flag taking an optional argument value, with an optional -- value, a list of flag names, an update function, the type of the -- argument and some help text. flagOpt :: String -> [Name] -> Update a -> FlagHelp -> Help -> Flag a -- | Create a flag taking no argument value, with a list of flag names, an -- update function and some help text. flagNone :: [Name] -> (a -> a) -> Help -> Flag a -- | Create a list of modes, with a program name, an initial value, some -- help text and the child modes. modes :: String -> a -> Help -> [Mode a] -> Mode a -- | Create a mode with a name, an initial value, some help text, a way of -- processing arguments and a list of flags. mode :: Name -> a -> Help -> Arg a -> [Flag a] -> Mode a -- | Create an empty mode specifying only modeValue. All other -- fields will usually be populated using record updates. modeEmpty :: a -> Mode a -- | Version of remap for the Update type alias. remapUpdate :: (a -> b) -> (b -> (a, a -> b)) -> Update a -> Update b -- | Restricted version of remap where the values are isomorphic. remap2 :: Remap m => (a -> b) -> (b -> a) -> m a -> m b -- | Check that a mode is well formed. checkMode :: Mode a -> Maybe String -- | Extract the value from inside a FlagOpt or FlagOptRare, -- or raises an error. fromFlagOpt :: FlagInfo -> String -- | Extract the flags from a Mode modeFlags :: Mode a -> [Flag a] -- | Extract the modes from a Mode modeModes :: Mode a -> [Mode a] -- | Convert a list into a group, placing all fields in -- groupUnnamed. toGroup :: [a] -> Group a -- | Convert a group into a list. fromGroup :: Group a -> [a] -- | Parse a boolean, accepts as True: true yes on enabled 1. parseBool :: String -> Maybe Bool -- | A help message that goes with either a flag or a mode. type Help = String -- | The type of a flag, i.e. --foo=TYPE. type FlagHelp = String -- | A group of items (modes or flags). The items are treated as a list, -- but the group structure is used when displaying the help message. data Group a Group :: [a] -> [a] -> [(Help, [a])] -> Group a -- | Normal items. [groupUnnamed] :: Group a -> [a] -- | Items that are hidden (not displayed in the help message). [groupHidden] :: Group a -> [a] -- | Items that have been grouped, along with a description of each group. [groupNamed] :: Group a -> [(Help, [a])] -- | A mode. Do not use the Mode constructor directly, instead use -- mode to construct the Mode and then record updates. Each -- mode has three main features: -- -- -- -- To produce the help information for a mode, either use -- helpText or show. data Mode a Mode :: Group (Mode a) -> [Name] -> a -> (a -> Either String a) -> (a -> Maybe [String]) -> Bool -> Help -> [String] -> ([Arg a], Maybe (Arg a)) -> Group (Flag a) -> Mode a -- | The available sub-modes [modeGroupModes] :: Mode a -> Group (Mode a) -- | The names assigned to this mode (for the root mode, this name is used -- as the program name) [modeNames] :: Mode a -> [Name] -- | Value to start with [modeValue] :: Mode a -> a -- | Check the value reprsented by a mode is correct, after applying all -- flags [modeCheck] :: Mode a -> a -> Either String a -- | Given a value, try to generate the input arguments. [modeReform] :: Mode a -> a -> Maybe [String] -- | Expand @ arguments with expandArgsAt, defaults to -- True, only applied if using an IO processing function. -- Only the root Modes value will be used. [modeExpandAt] :: Mode a -> Bool -- | Help text [modeHelp] :: Mode a -> Help -- | A longer help suffix displayed after a mode [modeHelpSuffix] :: Mode a -> [String] -- | The unnamed arguments, a series of arguments, followed optionally by -- one for all remaining slots [modeArgs] :: Mode a -> ([Arg a], Maybe (Arg a)) -- | Groups of flags [modeGroupFlags] :: Mode a -> Group (Flag a) -- | The FlagInfo type has the following meaning: -- --
--                FlagReq     FlagOpt      FlagOptRare/FlagNone
--   -xfoo        -x=foo      -x=foo       -x -foo
--   -x foo       -x=foo      -x foo       -x foo
--   -x=foo       -x=foo      -x=foo       -x=foo
--   --xx foo     --xx=foo    --xx foo     --xx foo
--   --xx=foo     --xx=foo    --xx=foo     --xx=foo
--   
data FlagInfo -- | Required argument FlagReq :: FlagInfo -- | Optional argument FlagOpt :: String -> FlagInfo -- | Optional argument that requires an = before the value FlagOptRare :: String -> FlagInfo -- | No argument FlagNone :: FlagInfo -- | A function to take a string, and a value, and either produce an error -- message (Left), or a modified value (Right). type Update a = String -> a -> Either String a -- | A flag, consisting of a list of flag names and other information. data Flag a Flag :: [Name] -> FlagInfo -> Update a -> FlagHelp -> Help -> Flag a -- | The names for the flag. [flagNames] :: Flag a -> [Name] -- | Information about a flag's arguments. [flagInfo] :: Flag a -> FlagInfo -- | The way of processing a flag. [flagValue] :: Flag a -> Update a -- | The type of data for the flag argument, i.e. FILE/DIR/EXT [flagType] :: Flag a -> FlagHelp -- | The help message associated with this flag. [flagHelp] :: Flag a -> Help -- | An unnamed argument. Anything not starting with - is -- considered an argument, apart from "-" which is considered to -- be the argument "-", and any arguments following -- "--". For example: -- --
--   programname arg1 -j - --foo arg3 -- -arg4 --arg5=1 arg6
--   
-- -- Would have the arguments: -- --
--   ["arg1","-","arg3","-arg4","--arg5=1","arg6"]
--   
data Arg a Arg :: Update a -> FlagHelp -> Bool -> Arg a -- | A way of processing the argument. [argValue] :: Arg a -> Update a -- | The type of data for the argument, i.e. FILE/DIR/EXT [argType] :: Arg a -> FlagHelp -- | Is at least one of these arguments required, the command line will -- fail if none are set [argRequire] :: Arg a -> Bool -- | Like functor, but where the the argument isn't just covariant. class Remap (m :: Type -> Type) -- | Convert between two values. remap :: Remap m => (a -> b) -> (b -> (a, a -> b)) -> m a -> m b -- | Given a string, split into the available arguments. The inverse of -- joinArgs. splitArgs :: String -> [String] -- | Given a sequence of arguments, join them together in a manner that -- could be used on the command line, giving preference to the Windows -- cmd shell quoting conventions. -- -- For an alternative version, intended for actual running the result in -- a shell, see "System.Process.showCommandForUser" joinArgs :: [String] -> String -- | Expand @ directives in a list of arguments, usually obtained -- from getArgs. As an example, given the file test.txt -- with the lines hello and world: -- --
--   expandArgsAt ["@test.txt","!"] == ["hello","world","!"]
--   
-- -- Any @ directives in the files will be recursively expanded -- (raising an error if there is infinite recursion). -- -- To supress @ expansion, pass any @ arguments after -- --. expandArgsAt :: [String] -> IO [String] -- | hledger - a ledger-compatible accounting tool. Copyright (c) 2007-2011 -- Simon Michael simon@joyful.com Released under GPL version 3 or -- later. -- -- hledger is a partial haskell clone of John Wiegley's "ledger". It -- generates ledger-compatible register & balance reports from a -- plain text journal, and demonstrates a functional implementation of -- ledger. For more information, see http://hledger.org . -- -- This module provides the main function for the hledger command-line -- executable. It is exposed here so that it can be imported by eg -- benchmark scripts. -- -- You can use the command line: -- --
--   $ hledger --help
--   
-- -- or ghci: -- --
--   $ ghci hledger
--   > Right j <- readJournalFile definputopts "examples/sample.journal"
--   > register [] ["income","expenses"] j
--   2008/01/01 income               income:salary                   $-1          $-1
--   2008/06/01 gift                 income:gifts                    $-1          $-2
--   2008/06/03 eat & shop           expenses:food                    $1          $-1
--                                   expenses:supplies                $1            0
--   > balance [Depth "1"] [] l
--                    $-1  assets
--                     $2  expenses
--                    $-2  income
--                     $1  liabilities
--   > j <- defaultJournal
--   
-- -- etc. module Hledger.Cli.Main -- | The overall cmdargs mode describing hledger's command-line options and -- subcommands. mainmode :: [Name] -> Mode RawOpts -- | Let's go! main :: IO () -- | Parse hledger CLI options from these command line arguments and add-on -- command names, or raise any error. argsToCliOpts :: [String] -> [String] -> IO CliOpts -- | A hacky workaround for cmdargs not accepting flags before the -- subcommand name: try to detect and move such flags after the command. -- This allows the user to put them in either position. The order of -- options is not preserved, but this should be ok. -- -- Since we're not parsing flags as precisely as cmdargs here, this is -- imperfect. We make a decent effort to: - move all no-argument -- helpinputreport flags - move all required-argument -- helpinputreport flags along with their values, space-separated -- or not - not confuse things further or cause misleading errors. moveFlagsAfterCommand :: [String] -> [String] isMovableNoArgFlag :: [Char] -> Bool isMovableReqArgFlag :: [Char] -> Bool isMovableReqArgFlagAndValue :: [Char] -> Bool isValue :: [Char] -> Bool flagstomove :: [Flag RawOpts] noargflagstomove :: [Name] reqargflagstomove :: [Name]