bal/etc.: document html output, move to options section

This commit is contained in:
Simon Michael 2018-01-23 17:08:19 -08:00
parent 37555617b7
commit e657e96591
6 changed files with 367 additions and 350 deletions

View File

@ -987,6 +987,33 @@ directives, not transaction prices (unlike Ledger).
Using \-B/\[en]cost and \-V/\[en]value together is currently allowed, Using \-B/\[en]cost and \-V/\[en]value together is currently allowed,
but the results are probably not meaningful. but the results are probably not meaningful.
Let us know if you find a use for this. Let us know if you find a use for this.
.SS Output destination
.PP
Some commands (print, register, stats, the balance commands) can write
their output to a destination other than the console.
This is controlled by the \f[C]\-o/\-\-output\-file\f[] option.
.IP
.nf
\f[C]
$\ hledger\ balance\ \-o\ \-\ \ \ \ \ #\ write\ to\ stdout\ (the\ default)
$\ hledger\ balance\ \-o\ FILE\ \ #\ write\ to\ FILE
\f[]
.fi
.SS Output format
.PP
Some commands can write their output in other formats.
Eg print and register can output CSV, and the balance commands can
output CSV or HTML.
This is controlled by the \f[C]\-O/\-\-output\-format\f[] option, or by
specifying a \f[C]\&.csv\f[] or \f[C]\&.html\f[] file extension with
\f[C]\-o/\-\-output\-file\f[].
.IP
.nf
\f[C]
$\ hledger\ balance\ \-O\ csv\ \ \ \ \ \ \ #\ write\ CSV\ to\ stdout
$\ hledger\ balance\ \-o\ FILE.csv\ \ #\ write\ CSV\ to\ FILE.csv
\f[]
.fi
.SS Regular expressions .SS Regular expressions
.PP .PP
hledger uses regular expressions in a number of places: hledger uses regular expressions in a number of places:
@ -1448,7 +1475,7 @@ in single\-column balance reports: use this custom line format
.TP .TP
.B \f[C]\-O\ FMT\ \-\-output\-format=FMT\f[] .B \f[C]\-O\ FMT\ \-\-output\-format=FMT\f[]
select the output format. select the output format.
Supported formats: txt, csv. Supported formats: txt, csv, html.
.RS .RS
.RE .RE
.TP .TP
@ -1798,8 +1825,8 @@ Balance\ changes\ in\ 2017/11/01\-2017/12/31:
For more examples and details, see Budgeting and Forecasting. For more examples and details, see Budgeting and Forecasting.
.SS Custom balance output .SS Custom balance output
.PP .PP
In simple (non\-multi\-column) balance reports, you can customise the You can customise the layout of simple (non\-tabular) balance reports
output with \f[C]\-\-format\ FMT\f[]: with \f[C]\-\-format\ FMT\f[]:
.IP .IP
.nf .nf
\f[C] \f[C]
@ -1867,6 +1894,8 @@ rendered on one line
.IP \[bu] 2 .IP \[bu] 2
\f[C]%20(total)\ \ %2(depth_spacer)%\-(account)\f[] \- the default \f[C]%20(total)\ \ %2(depth_spacer)%\-(account)\f[] \- the default
format for the single\-column balance report format for the single\-column balance report
.PP
This command also supports output destination and output formats.
.SS Colour support .SS Colour support
.PP .PP
The balance command shows negative amounts in red, if: The balance command shows negative amounts in red, if:
@ -1874,33 +1903,6 @@ The balance command shows negative amounts in red, if:
the \f[C]TERM\f[] environment variable is not set to \f[C]dumb\f[] the \f[C]TERM\f[] environment variable is not set to \f[C]dumb\f[]
.IP \[bu] 2 .IP \[bu] 2
the output is not being redirected or piped anywhere the output is not being redirected or piped anywhere
.SS Output destination
.PP
The balance, print, register and stats commands can write their output
to a destination other than the console.
This is controlled by the \f[C]\-o/\-\-output\-file\f[] option.
.IP
.nf
\f[C]
$\ hledger\ balance\ \-o\ \-\ \ \ \ \ #\ write\ to\ stdout\ (the\ default)
$\ hledger\ balance\ \-o\ FILE\ \ #\ write\ to\ FILE
\f[]
.fi
.SS CSV output
.PP
The balance, print and register commands can write their output as CSV.
This is useful for exporting data to other applications, eg to make
charts in a spreadsheet.
This is controlled by the \f[C]\-O/\-\-output\-format\f[] option, or by
specifying a \f[C]\&.csv\f[] file extension with
\f[C]\-o/\-\-output\-file\f[].
.IP
.nf
\f[C]
$\ hledger\ balance\ \-O\ csv\ \ \ \ \ \ \ #\ write\ CSV\ to\ stdout
$\ hledger\ balance\ \-o\ FILE.csv\ \ #\ write\ CSV\ to\ FILE.csv
\f[]
.fi
.SS balancesheet .SS balancesheet
.PP .PP
This command displays a simple balance sheet, showing historical ending This command displays a simple balance sheet, showing historical ending
@ -2011,6 +2013,8 @@ As with multicolumn balance reports, you can alter the report mode with
Normally balancesheet shows historical ending balances, which is what Normally balancesheet shows historical ending balances, which is what
you need for a balance sheet; note this means it ignores report begin you need for a balance sheet; note this means it ignores report begin
dates. dates.
.PP
This command also supports output destination and output formats.
.SS balancesheetequity .SS balancesheetequity
.PP .PP
Just like balancesheet, but also reports Equity (which it assumes is Just like balancesheet, but also reports Equity (which it assumes is
@ -2146,6 +2150,8 @@ report period.
Normally cashflow shows changes in assets per period, though as with Normally cashflow shows changes in assets per period, though as with
multicolumn balance reports you can alter the report mode with multicolumn balance reports you can alter the report mode with
\f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[]. \f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[].
.PP
This command also supports output destination and output formats.
.SS check\-dates .SS check\-dates
.PP .PP
Check that transactions are sorted by increasing date. Check that transactions are sorted by increasing date.
@ -2343,6 +2349,8 @@ report period.
Normally incomestatement shows revenues/expenses per period, though as Normally incomestatement shows revenues/expenses per period, though as
with multicolumn balance reports you can alter the report mode with with multicolumn balance reports you can alter the report mode with
\f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[]. \f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[].
.PP
This command also supports output destination and output formats.
.SS prices .SS prices
.PP .PP
Print all market prices from the journal. Print all market prices from the journal.
@ -2455,7 +2463,7 @@ increasing dates, and that transactions on the same day do not get
reordered. reordered.
See also the import command. See also the import command.
.PP .PP
The print command also supports output destination and CSV output. This command also supports output destination and output formats.
Here's an example of print's CSV output: Here's an example of print's CSV output:
.IP .IP
.nf .nf
@ -2667,9 +2675,7 @@ $\ hledger\ reg\ \-w\ $COLUMNS,40\ \ \ \ \ \ #\ use\ terminal\ width,\ and\ set\
\f[] \f[]
.fi .fi
.PP .PP
The register command also supports the \f[C]\-o/\-\-output\-file\f[] and This command also supports output destination and output formats.
\f[C]\-O/\-\-output\-format\f[] options for controlling output
destination and CSV output.
.SS register\-match .SS register\-match
.PP .PP
Print the one posting whose transaction description is closest to DESC, Print the one posting whose transaction description is closest to DESC,
@ -2708,8 +2714,7 @@ The stats command displays summary information for the whole journal, or
a matched part of it. a matched part of it.
With a reporting interval, it shows a report for each report period. With a reporting interval, it shows a report for each report period.
.PP .PP
The stats command also supports \f[C]\-o/\-\-output\-file\f[] for This command also supports output destination and output formats.
controlling output destination.
.SS tags .SS tags
.PP .PP
List all the tag names used in the journal. List all the tag names used in the journal.

View File

@ -681,6 +681,37 @@ File: hledger.info, Node: Combining -B and -V, Next: Regular expressions, Pre
Using -B/-cost and -V/-value together is currently allowed, but the Using -B/-cost and -V/-value together is currently allowed, but the
results are probably not meaningful. Let us know if you find a use for results are probably not meaningful. Let us know if you find a use for
this. this.
* Menu:
* Output destination::
* Output format::

File: hledger.info, Node: Output destination, Next: Output format, Up: Combining -B and -V
2.15.1 Output destination
-------------------------
Some commands (print, register, stats, the balance commands) can write
their output to a destination other than the console. This is
controlled by the '-o/--output-file' option.
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE

File: hledger.info, Node: Output format, Prev: Output destination, Up: Combining -B and -V
2.15.2 Output format
--------------------
Some commands can write their output in other formats. Eg print and
register can output CSV, and the balance commands can output CSV or
HTML. This is controlled by the '-O/--output-format' option, or by
specifying a '.csv' or '.html' file extension with '-o/--output-file'.
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
 
File: hledger.info, Node: Regular expressions, Prev: Combining -B and -V, Up: OPTIONS File: hledger.info, Node: Regular expressions, Prev: Combining -B and -V, Up: OPTIONS
@ -1084,7 +1115,7 @@ Show accounts and their balances. Aliases: b, bal.
in single-column balance reports: use this custom line format in single-column balance reports: use this custom line format
'-O FMT --output-format=FMT' '-O FMT --output-format=FMT'
select the output format. Supported formats: txt, csv. select the output format. Supported formats: txt, csv, html.
'-o FILE --output-file=FILE' '-o FILE --output-file=FILE'
write output to FILE. A file extension matching one of the above write output to FILE. A file extension matching one of the above
@ -1159,8 +1190,6 @@ $ hledger balance -p 2008/6 expenses --no-total
* Budgets:: * Budgets::
* Custom balance output:: * Custom balance output::
* Colour support:: * Colour support::
* Output destination::
* CSV output::
 
File: hledger.info, Node: Flat mode, Next: Depth limited balance reports, Up: balance File: hledger.info, Node: Flat mode, Next: Depth limited balance reports, Up: balance
@ -1393,8 +1422,8 @@ File: hledger.info, Node: Custom balance output, Next: Colour support, Prev:
4.4.5 Custom balance output 4.4.5 Custom balance output
--------------------------- ---------------------------
In simple (non-multi-column) balance reports, you can customise the You can customise the layout of simple (non-tabular) balance reports
output with '--format FMT': with '--format FMT':
$ hledger balance --format "%20(account) %12(total)" $ hledger balance --format "%20(account) %12(total)"
assets $-1 assets $-1
@ -1447,8 +1476,10 @@ may be needed to get pleasing results.
* '%20(total) %2(depth_spacer)%-(account)' - the default format for * '%20(total) %2(depth_spacer)%-(account)' - the default format for
the single-column balance report the single-column balance report
This command also supports output destination and output formats.
 
File: hledger.info, Node: Colour support, Next: Output destination, Prev: Custom balance output, Up: balance File: hledger.info, Node: Colour support, Prev: Custom balance output, Up: balance
4.4.6 Colour support 4.4.6 Colour support
-------------------- --------------------
@ -1458,34 +1489,6 @@ The balance command shows negative amounts in red, if:
* the 'TERM' environment variable is not set to 'dumb' * the 'TERM' environment variable is not set to 'dumb'
* the output is not being redirected or piped anywhere * the output is not being redirected or piped anywhere

File: hledger.info, Node: Output destination, Next: CSV output, Prev: Colour support, Up: balance
4.4.7 Output destination
------------------------
The balance, print, register and stats commands can write their output
to a destination other than the console. This is controlled by the
'-o/--output-file' option.
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE

File: hledger.info, Node: CSV output, Prev: Output destination, Up: balance
4.4.8 CSV output
----------------
The balance, print and register commands can write their output as CSV.
This is useful for exporting data to other applications, eg to make
charts in a spreadsheet. This is controlled by the '-O/--output-format'
option, or by specifying a '.csv' file extension with
'-o/--output-file'.
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
 
File: hledger.info, Node: balancesheet, Next: balancesheetequity, Prev: balance, Up: COMMANDS File: hledger.info, Node: balancesheet, Next: balancesheetequity, Prev: balance, Up: COMMANDS
@ -1569,6 +1572,8 @@ the report mode with '--change'/'--cumulative'/'--historical'. Normally
balancesheet shows historical ending balances, which is what you need balancesheet shows historical ending balances, which is what you need
for a balance sheet; note this means it ignores report begin dates. for a balance sheet; note this means it ignores report begin dates.
This command also supports output destination and output formats.
 
File: hledger.info, Node: balancesheetequity, Next: cashflow, Prev: balancesheet, Up: COMMANDS File: hledger.info, Node: balancesheetequity, Next: cashflow, Prev: balancesheet, Up: COMMANDS
@ -1679,6 +1684,8 @@ each report period. Normally cashflow shows changes in assets per
period, though as with multicolumn balance reports you can alter the period, though as with multicolumn balance reports you can alter the
report mode with '--change'/'--cumulative'/'--historical'. report mode with '--change'/'--cumulative'/'--historical'.
This command also supports output destination and output formats.
 
File: hledger.info, Node: check-dates, Next: check-dupes, Prev: cashflow, Up: COMMANDS File: hledger.info, Node: check-dates, Next: check-dupes, Prev: cashflow, Up: COMMANDS
@ -1856,6 +1863,8 @@ each report period. Normally incomestatement shows revenues/expenses
per period, though as with multicolumn balance reports you can alter the per period, though as with multicolumn balance reports you can alter the
report mode with '--change'/'--cumulative'/'--historical'. report mode with '--change'/'--cumulative'/'--historical'.
This command also supports output destination and output formats.
 
File: hledger.info, Node: prices, Next: print, Prev: incomestatement, Up: COMMANDS File: hledger.info, Node: prices, Next: print, Prev: incomestatement, Up: COMMANDS
@ -1951,7 +1960,7 @@ $ hledger -f bank1.csv print --new
increasing dates, and that transactions on the same day do not get increasing dates, and that transactions on the same day do not get
reordered. See also the import command. reordered. See also the import command.
The print command also supports output destination and CSV output. This command also supports output destination and output formats.
Here's an example of print's CSV output: Here's an example of print's CSV output:
$ hledger print -Ocsv $ hledger print -Ocsv
@ -2122,9 +2131,7 @@ $ export COLUMNS=100; hledger reg # set till session end (or window resize)
$ hledger reg -w 100,40 # set overall width 100, description width 40 $ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width $ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
The register command also supports the '-o/--output-file' and This command also supports output destination and output formats.
'-O/--output-format' options for controlling output destination and CSV
output.
 
File: hledger.info, Node: register-match, Next: rewrite, Prev: register, Up: COMMANDS File: hledger.info, Node: register-match, Next: rewrite, Prev: register, Up: COMMANDS
@ -2173,8 +2180,7 @@ Commodities : 1 ($)
or a matched part of it. With a reporting interval, it shows a report or a matched part of it. With a reporting interval, it shows a report
for each report period. for each report period.
The stats command also supports '-o/--output-file' for controlling This command also supports output destination and output formats.
output destination.
 
File: hledger.info, Node: tags, Next: test, Prev: stats, Up: COMMANDS File: hledger.info, Node: tags, Next: test, Prev: stats, Up: COMMANDS
@ -2418,103 +2424,103 @@ Node: Market value21197
Ref: #market-value21332 Ref: #market-value21332
Node: Combining -B and -V22515 Node: Combining -B and -V22515
Ref: #combining--b-and--v22679 Ref: #combining--b-and--v22679
Node: Regular expressions22826 Node: Output destination22876
Ref: #regular-expressions22969 Ref: #output-destination23026
Node: QUERIES24330 Node: Output format23309
Ref: #queries24432 Ref: #output-format23449
Node: COMMANDS28399 Node: Regular expressions23834
Ref: #commands28511 Ref: #regular-expressions23977
Node: accounts29493 Node: QUERIES25338
Ref: #accounts29591 Ref: #queries25440
Node: activity30837 Node: COMMANDS29407
Ref: #activity30947 Ref: #commands29519
Node: add31307 Node: accounts30501
Ref: #add31406 Ref: #accounts30599
Node: balance34067 Node: activity31845
Ref: #balance34178 Ref: #activity31955
Node: Flat mode37658 Node: add32315
Ref: #flat-mode37783 Ref: #add32414
Node: Depth limited balance reports38203 Node: balance35075
Ref: #depth-limited-balance-reports38404 Ref: #balance35186
Node: Multicolumn balance reports38824 Node: Flat mode38634
Ref: #multicolumn-balance-reports39019 Ref: #flat-mode38759
Node: Budgets43708 Node: Depth limited balance reports39179
Ref: #budgets43855 Ref: #depth-limited-balance-reports39380
Node: Custom balance output47686 Node: Multicolumn balance reports39800
Ref: #custom-balance-output47848 Ref: #multicolumn-balance-reports39995
Node: Colour support49941 Node: Budgets44684
Ref: #colour-support50100 Ref: #budgets44831
Node: Output destination50273 Node: Custom balance output48662
Ref: #output-destination50429 Ref: #custom-balance-output48824
Node: CSV output50699 Node: Colour support50981
Ref: #csv-output50816 Ref: #colour-support51113
Node: balancesheet51213 Node: balancesheet51286
Ref: #balancesheet51349 Ref: #balancesheet51422
Node: balancesheetequity53581 Node: balancesheetequity53724
Ref: #balancesheetequity53730 Ref: #balancesheetequity53873
Node: cashflow54267 Node: cashflow54410
Ref: #cashflow54395 Ref: #cashflow54538
Node: check-dates56439 Node: check-dates56652
Ref: #check-dates56566 Ref: #check-dates56779
Node: check-dupes56683 Node: check-dupes56896
Ref: #check-dupes56807 Ref: #check-dupes57020
Node: close56944 Node: close57157
Ref: #close57051 Ref: #close57264
Node: help57381 Node: help57594
Ref: #help57481 Ref: #help57694
Node: import58555 Node: import58768
Ref: #import58669 Ref: #import58882
Node: incomestatement59399 Node: incomestatement59612
Ref: #incomestatement59533 Ref: #incomestatement59746
Node: prices61858 Node: prices62141
Ref: #prices61973 Ref: #prices62256
Node: print62016 Node: print62299
Ref: #print62126 Ref: #print62409
Node: print-unique67011 Node: print-unique67293
Ref: #print-unique67137 Ref: #print-unique67419
Node: register67205 Node: register67487
Ref: #register67332 Ref: #register67614
Node: Custom register output71833 Node: Custom register output72115
Ref: #custom-register-output71962 Ref: #custom-register-output72244
Node: register-match73259 Node: register-match73465
Ref: #register-match73393 Ref: #register-match73599
Node: rewrite73576 Node: rewrite73782
Ref: #rewrite73693 Ref: #rewrite73899
Node: stats73762 Node: stats73968
Ref: #stats73865 Ref: #stats74071
Node: tags74747 Node: tags74932
Ref: #tags74845 Ref: #tags75030
Node: test75081 Node: test75266
Ref: #test75165 Ref: #test75350
Node: ADD-ON COMMANDS75533 Node: ADD-ON COMMANDS75718
Ref: #add-on-commands75643 Ref: #add-on-commands75828
Node: Official add-ons76930 Node: Official add-ons77115
Ref: #official-add-ons77070 Ref: #official-add-ons77255
Node: api77157 Node: api77342
Ref: #api77246 Ref: #api77431
Node: ui77298 Node: ui77483
Ref: #ui77397 Ref: #ui77582
Node: web77455 Node: web77640
Ref: #web77544 Ref: #web77729
Node: Third party add-ons77590 Node: Third party add-ons77775
Ref: #third-party-add-ons77765 Ref: #third-party-add-ons77950
Node: diff77900 Node: diff78085
Ref: #diff77997 Ref: #diff78182
Node: iadd78096 Node: iadd78281
Ref: #iadd78210 Ref: #iadd78395
Node: interest78293 Node: interest78478
Ref: #interest78414 Ref: #interest78599
Node: irr78509 Node: irr78694
Ref: #irr78607 Ref: #irr78792
Node: Experimental add-ons78685 Node: Experimental add-ons78870
Ref: #experimental-add-ons78837 Ref: #experimental-add-ons79022
Node: autosync79128 Node: autosync79313
Ref: #autosync79240 Ref: #autosync79425
Node: budget79479 Node: budget79664
Ref: #budget79601 Ref: #budget79786
Node: chart79667 Node: chart79852
Ref: #chart79784 Ref: #chart79969
Node: check79855 Node: check80040
Ref: #check79957 Ref: #check80142
 
End Tag Table End Tag Table

View File

@ -635,59 +635,76 @@ OPTIONS
results are probably not meaningful. Let us know if you find a use for results are probably not meaningful. Let us know if you find a use for
this. this.
Output destination
Some commands (print, register, stats, the balance commands) can write
their output to a destination other than the console. This is con-
trolled by the -o/--output-file option.
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE
Output format
Some commands can write their output in other formats. Eg print and
register can output CSV, and the balance commands can output CSV or
HTML. This is controlled by the -O/--output-format option, or by spec-
ifying a .csv or .html file extension with -o/--output-file.
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
Regular expressions Regular expressions
hledger uses regular expressions in a number of places: hledger uses regular expressions in a number of places:
o query terms, on the command line and in the hledger-web search form: o query terms, on the command line and in the hledger-web search form:
REGEX, desc:REGEX, cur:REGEX, tag:...=REGEX REGEX, desc:REGEX, cur:REGEX, tag:...=REGEX
o CSV rules conditional blocks: if REGEX ... o CSV rules conditional blocks: if REGEX ...
o account alias directives and options: alias /REGEX/ = REPLACEMENT, o account alias directives and options: alias /REGEX/ = REPLACEMENT,
--alias /REGEX/=REPLACEMENT --alias /REGEX/=REPLACEMENT
hledger's regular expressions come from the regex-tdfa library. In hledger's regular expressions come from the regex-tdfa library. In
general they: general they:
o are case insensitive o are case insensitive
o are infix matching (do not need to match the entire thing being o are infix matching (do not need to match the entire thing being
matched) matched)
o are POSIX extended regular expressions o are POSIX extended regular expressions
o also support GNU word boundaries (\<, \>, \b, \B) o also support GNU word boundaries (\<, \>, \b, \B)
o and parenthesised capturing groups and numeric backreferences in o and parenthesised capturing groups and numeric backreferences in
replacement strings replacement strings
o do not support mode modifiers like (?s) o do not support mode modifiers like (?s)
Some things to note: Some things to note:
o In the alias directive and --alias option, regular expressions must o In the alias directive and --alias option, regular expressions must
be enclosed in forward slashes (/REGEX/). Elsewhere in hledger, be enclosed in forward slashes (/REGEX/). Elsewhere in hledger,
these are not required. these are not required.
o In queries, to match a regular expression metacharacter like $ as a o In queries, to match a regular expression metacharacter like $ as a
literal character, prepend a backslash. Eg to search for amounts literal character, prepend a backslash. Eg to search for amounts
with the dollar sign in hledger-web, write cur:\$. with the dollar sign in hledger-web, write cur:\$.
o On the command line, some metacharacters like $ have a special mean- o On the command line, some metacharacters like $ have a special mean-
ing to the shell and so must be escaped at least once more. See Spe- ing to the shell and so must be escaped at least once more. See Spe-
cial characters. cial characters.
QUERIES QUERIES
One of hledger's strengths is being able to quickly report on precise One of hledger's strengths is being able to quickly report on precise
subsets of your data. Most commands accept an optional query expres- subsets of your data. Most commands accept an optional query expres-
sion, written as arguments after the command name, to filter the data sion, written as arguments after the command name, to filter the data
by date, account name or other criteria. The syntax is similar to a by date, account name or other criteria. The syntax is similar to a
web search: one or more space-separated search terms, quotes to enclose web search: one or more space-separated search terms, quotes to enclose
whitespace, prefixes to match specific fields, a not: prefix to negate whitespace, prefixes to match specific fields, a not: prefix to negate
the match. the match.
We do not yet support arbitrary boolean combinations of search terms; We do not yet support arbitrary boolean combinations of search terms;
instead most commands show transactions/postings/accounts which match instead most commands show transactions/postings/accounts which match
(or negatively match): (or negatively match):
o any of the description terms AND o any of the description terms AND
@ -708,32 +725,32 @@ QUERIES
o match all the other terms. o match all the other terms.
The following kinds of search terms can be used. Remember these can The following kinds of search terms can be used. Remember these can
also be prefixed with not:, eg to exclude a particular subaccount. also be prefixed with not:, eg to exclude a particular subaccount.
REGEX match account names by this regular expression. (No prefix is REGEX match account names by this regular expression. (No prefix is
equivalent to acct:). equivalent to acct:).
acct:REGEX acct:REGEX
same as above same as above
amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N
match postings with a single-commodity amount that is equal to, match postings with a single-commodity amount that is equal to,
less than, or greater than N. (Multi-commodity amounts are not less than, or greater than N. (Multi-commodity amounts are not
tested, and will always match.) The comparison has two modes: if tested, and will always match.) The comparison has two modes: if
N is preceded by a + or - sign (or is 0), the two signed numbers N is preceded by a + or - sign (or is 0), the two signed numbers
are compared. Otherwise, the absolute magnitudes are compared, are compared. Otherwise, the absolute magnitudes are compared,
ignoring sign. ignoring sign.
code:REGEX code:REGEX
match by transaction code (eg check number) match by transaction code (eg check number)
cur:REGEX cur:REGEX
match postings or transactions including any amounts whose cur- match postings or transactions including any amounts whose cur-
rency/commodity symbol is fully matched by REGEX. (For a par- rency/commodity symbol is fully matched by REGEX. (For a par-
tial match, use .*REGEX.*). Note, to match characters which are tial match, use .*REGEX.*). Note, to match characters which are
regex-significant, like the dollar sign ($), you need to prepend regex-significant, like the dollar sign ($), you need to prepend
\. And when using the command line you need to add one more \. And when using the command line you need to add one more
level of quoting to hide it from the shell, so eg do: level of quoting to hide it from the shell, so eg do:
hledger print cur:'\$' or hledger print cur:\\$. hledger print cur:'\$' or hledger print cur:\\$.
@ -742,20 +759,20 @@ QUERIES
date:PERIODEXPR date:PERIODEXPR
match dates within the specified period. PERIODEXPR is a period match dates within the specified period. PERIODEXPR is a period
expression (with no report interval). Examples: date:2016, expression (with no report interval). Examples: date:2016,
date:thismonth, date:2000/2/1-2/15, date:lastweek-. If the date:thismonth, date:2000/2/1-2/15, date:lastweek-. If the
--date2 command line flag is present, this matches secondary --date2 command line flag is present, this matches secondary
dates instead. dates instead.
date2:PERIODEXPR date2:PERIODEXPR
match secondary dates within the specified period. match secondary dates within the specified period.
depth:N depth:N
match (or display, depending on command) accounts at or above match (or display, depending on command) accounts at or above
this depth this depth
note:REGEX note:REGEX
match transaction notes (part of description right of |, or match transaction notes (part of description right of |, or
whole description when there's no |) whole description when there's no |)
payee:REGEX payee:REGEX
@ -769,38 +786,38 @@ QUERIES
match unmarked, pending, or cleared transactions respectively match unmarked, pending, or cleared transactions respectively
tag:REGEX[=REGEX] tag:REGEX[=REGEX]
match by tag name, and optionally also by tag value. Note a match by tag name, and optionally also by tag value. Note a
tag: query is considered to match a transaction if it matches tag: query is considered to match a transaction if it matches
any of the postings. Also remember that postings inherit the any of the postings. Also remember that postings inherit the
tags of their parent transaction. tags of their parent transaction.
The following special search term is used automatically in hledger-web, The following special search term is used automatically in hledger-web,
only: only:
inacct:ACCTNAME inacct:ACCTNAME
tells hledger-web to show the transaction register for this tells hledger-web to show the transaction register for this
account. Can be filtered further with acct etc. account. Can be filtered further with acct etc.
Some of these can also be expressed as command-line options (eg depth:2 Some of these can also be expressed as command-line options (eg depth:2
is equivalent to --depth 2). Generally you can mix options and query is equivalent to --depth 2). Generally you can mix options and query
arguments, and the resulting query will be their intersection (perhaps arguments, and the resulting query will be their intersection (perhaps
excluding the -p/--period option). excluding the -p/--period option).
COMMANDS COMMANDS
hledger provides a number of subcommands; hledger with no arguments hledger provides a number of subcommands; hledger with no arguments
shows a list. shows a list.
If you install additional hledger-* packages, or if you put programs or If you install additional hledger-* packages, or if you put programs or
scripts named hledger-NAME in your PATH, these will also be listed as scripts named hledger-NAME in your PATH, these will also be listed as
subcommands. subcommands.
Run a subcommand by writing its name as first argument (eg Run a subcommand by writing its name as first argument (eg
hledger incomestatement). You can also write one of the standard short hledger incomestatement). You can also write one of the standard short
aliases displayed in parentheses in the command list (hledger b), or aliases displayed in parentheses in the command list (hledger b), or
any any unambiguous prefix of a command name (hledger inc). any any unambiguous prefix of a command name (hledger inc).
Here are all the builtin commands in alphabetical order. See also Here are all the builtin commands in alphabetical order. See also
hledger for a more organised command list, and hledger CMD -h for hledger for a more organised command list, and hledger CMD -h for
detailed command help. detailed command help.
accounts accounts
@ -818,12 +835,12 @@ COMMANDS
--drop=N --drop=N
in flat mode: omit N leading account name parts in flat mode: omit N leading account name parts
This command lists account names, either declared with account direc- This command lists account names, either declared with account direc-
tives (-declared), posted to (-used), or both (default). With query tives (-declared), posted to (-used), or both (default). With query
arguments, only matched account names and account names referenced by arguments, only matched account names and account names referenced by
matched postings are shown. It shows a flat list by default. With matched postings are shown. It shows a flat list by default. With
--tree, it uses indentation to show the account hierarchy. In flat --tree, it uses indentation to show the account hierarchy. In flat
mode you can add --drop N to omit the first few account name compo- mode you can add --drop N to omit the first few account name compo-
nents. Account names can be depth-clipped with --depth N or depth:N. nents. Account names can be depth-clipped with --depth N or depth:N.
Examples: Examples:
@ -866,8 +883,8 @@ COMMANDS
activity activity
Show an ascii barchart of posting counts per interval. Show an ascii barchart of posting counts per interval.
The activity command displays an ascii histogram showing transaction The activity command displays an ascii histogram showing transaction
counts by day, week, month or other reporting interval (by day is the counts by day, week, month or other reporting interval (by day is the
default). With query arguments, it counts only matched transactions. default). With query arguments, it counts only matched transactions.
$ hledger activity --quarterly $ hledger activity --quarterly
@ -880,24 +897,24 @@ COMMANDS
Prompt for transactions and add them to the journal. Prompt for transactions and add them to the journal.
--no-new-accounts --no-new-accounts
don't allow creating new accounts; helps prevent typos when don't allow creating new accounts; helps prevent typos when
entering account names entering account names
Many hledger users edit their journals directly with a text editor, or Many hledger users edit their journals directly with a text editor, or
generate them from CSV. For more interactive data entry, there is the generate them from CSV. For more interactive data entry, there is the
add command, which prompts interactively on the console for new trans- add command, which prompts interactively on the console for new trans-
actions, and appends them to the journal file (if there are multiple actions, and appends them to the journal file (if there are multiple
-f FILE options, the first file is used.) Existing transactions are not -f FILE options, the first file is used.) Existing transactions are not
changed. This is the only hledger command that writes to the journal changed. This is the only hledger command that writes to the journal
file. file.
To use it, just run hledger add and follow the prompts. You can add as To use it, just run hledger add and follow the prompts. You can add as
many transactions as you like; when you are finished, enter . or press many transactions as you like; when you are finished, enter . or press
control-d or control-c to exit. control-d or control-c to exit.
Features: Features:
o add tries to provide useful defaults, using the most similar recent o add tries to provide useful defaults, using the most similar recent
transaction (by description) as a template. transaction (by description) as a template.
o You can also set the initial defaults with command line arguments. o You can also set the initial defaults with command line arguments.
@ -905,20 +922,20 @@ COMMANDS
o Readline-style edit keys can be used during data entry. o Readline-style edit keys can be used during data entry.
o The tab key will auto-complete whenever possible - accounts, descrip- o The tab key will auto-complete whenever possible - accounts, descrip-
tions, dates (yesterday, today, tomorrow). If the input area is tions, dates (yesterday, today, tomorrow). If the input area is
empty, it will insert the default value. empty, it will insert the default value.
o If the journal defines a default commodity, it will be added to any o If the journal defines a default commodity, it will be added to any
bare numbers entered. bare numbers entered.
o A parenthesised transaction code may be entered following a date. o A parenthesised transaction code may be entered following a date.
o Comments and tags may be entered following a description or amount. o Comments and tags may be entered following a description or amount.
o If you make a mistake, enter < at any prompt to restart the transac- o If you make a mistake, enter < at any prompt to restart the transac-
tion. tion.
o Input prompts are displayed in a different colour when the terminal o Input prompts are displayed in a different colour when the terminal
supports it. supports it.
Example (see the tutorial for a detailed explanation): Example (see the tutorial for a detailed explanation):
@ -955,7 +972,7 @@ COMMANDS
show balance change in each period (default) show balance change in each period (default)
--cumulative --cumulative
show balance change accumulated across periods (in multicolumn show balance change accumulated across periods (in multicolumn
reports) reports)
-H --historical -H --historical
@ -987,28 +1004,28 @@ COMMANDS
in single-column balance reports: use this custom line format in single-column balance reports: use this custom line format
-O FMT --output-format=FMT -O FMT --output-format=FMT
select the output format. Supported formats: txt, csv. select the output format. Supported formats: txt, csv, html.
-o FILE --output-file=FILE -o FILE --output-file=FILE
write output to FILE. A file extension matching one of the write output to FILE. A file extension matching one of the
above formats selects that format. above formats selects that format.
--pretty-tables --pretty-tables
use unicode to display prettier tables. use unicode to display prettier tables.
--sort-amount --sort-amount
sort by amount instead of account code/name (in flat mode). sort by amount instead of account code/name (in flat mode).
With multiple columns, sorts by the row total, or by row average With multiple columns, sorts by the row total, or by row average
if that is displayed. if that is displayed.
--budget --budget
show performance compared to budget goals defined by periodic show performance compared to budget goals defined by periodic
transactions transactions
--show-unbudgeted --show-unbudgeted
with -budget, show unbudgeted accounts also with -budget, show unbudgeted accounts also
The balance command displays accounts and balances. It is hledger's The balance command displays accounts and balances. It is hledger's
most featureful and versatile command. most featureful and versatile command.
$ hledger balance $ hledger balance
@ -1025,28 +1042,28 @@ COMMANDS
-------------------- --------------------
0 0
More precisely, the balance command shows the change to each account's More precisely, the balance command shows the change to each account's
balance caused by all (matched) postings. In the common case where you balance caused by all (matched) postings. In the common case where you
do not filter by date and your journal sets the correct opening bal- do not filter by date and your journal sets the correct opening bal-
ances, this is the same as the account's ending balance. ances, this is the same as the account's ending balance.
By default, accounts are displayed hierarchically, with subaccounts By default, accounts are displayed hierarchically, with subaccounts
indented below their parent. At each level of the tree, accounts are indented below their parent. At each level of the tree, accounts are
sorted by account code if any, then by account name. Or with sorted by account code if any, then by account name. Or with
-S/--sort-amount, by their balance amount. -S/--sort-amount, by their balance amount.
"Boring" accounts, which contain a single interesting subaccount and no "Boring" accounts, which contain a single interesting subaccount and no
balance of their own, are elided into the following line for more com- balance of their own, are elided into the following line for more com-
pact output. (Not yet supported in tabular reports.) Use --no-elide to pact output. (Not yet supported in tabular reports.) Use --no-elide to
prevent this. prevent this.
Account balances are "inclusive" - they include the balances of any Account balances are "inclusive" - they include the balances of any
subaccounts. subaccounts.
Accounts which have zero balance (and no non-zero subaccounts) are Accounts which have zero balance (and no non-zero subaccounts) are
omitted. Use -E/--empty to show them. omitted. Use -E/--empty to show them.
A final total is displayed by default; use -N/--no-total to suppress A final total is displayed by default; use -N/--no-total to suppress
it: it:
$ hledger balance -p 2008/6 expenses --no-total $ hledger balance -p 2008/6 expenses --no-total
@ -1056,9 +1073,9 @@ COMMANDS
Flat mode Flat mode
To see a flat list of full account names instead of the default hierar- To see a flat list of full account names instead of the default hierar-
chical display, use --flat. In this mode, accounts (unless chical display, use --flat. In this mode, accounts (unless
depth-clipped) show their "exclusive" balance, excluding any subaccount depth-clipped) show their "exclusive" balance, excluding any subaccount
balances. In this mode, you can also use --drop N to omit the first balances. In this mode, you can also use --drop N to omit the first
few account name components. few account name components.
$ hledger balance -p 2008/6 expenses -N --flat --drop 1 $ hledger balance -p 2008/6 expenses -N --flat --drop 1
@ -1066,9 +1083,9 @@ COMMANDS
$1 supplies $1 supplies
Depth limited balance reports Depth limited balance reports
With --depth N, balance shows accounts only to the specified depth. With --depth N, balance shows accounts only to the specified depth.
This is very useful to show a complex charts of accounts in less This is very useful to show a complex charts of accounts in less
detail. In flat mode, balances from accounts below the depth limit detail. In flat mode, balances from accounts below the depth limit
will be shown as part of a parent account at the depth limit. will be shown as part of a parent account at the depth limit.
$ hledger balance -N --depth 1 $ hledger balance -N --depth 1
@ -1078,12 +1095,12 @@ COMMANDS
$1 liabilities $1 liabilities
Multicolumn balance reports Multicolumn balance reports
With a reporting interval, multiple balance columns will be shown, one With a reporting interval, multiple balance columns will be shown, one
for each report period. There are three types of multi-column balance for each report period. There are three types of multi-column balance
report, showing different information: report, showing different information:
1. By default: each column shows the sum of postings in that period, ie 1. By default: each column shows the sum of postings in that period, ie
the account's change of balance in that period. This is useful eg the account's change of balance in that period. This is useful eg
for a monthly income statement: for a monthly income statement:
$ hledger balance --quarterly income expenses -E $ hledger balance --quarterly income expenses -E
@ -1098,8 +1115,8 @@ COMMANDS
-------------------++--------------------------------- -------------------++---------------------------------
|| $-1 $1 0 0 || $-1 $1 0 0
2. With --cumulative: each column shows the ending balance for that 2. With --cumulative: each column shows the ending balance for that
period, accumulating the changes across periods, starting from 0 at period, accumulating the changes across periods, starting from 0 at
the report start date: the report start date:
$ hledger balance --quarterly income expenses -E --cumulative $ hledger balance --quarterly income expenses -E --cumulative
@ -1115,8 +1132,8 @@ COMMANDS
|| $-1 0 0 0 || $-1 0 0 0
3. With --historical/-H: each column shows the actual historical ending 3. With --historical/-H: each column shows the actual historical ending
balance for that period, accumulating the changes across periods, balance for that period, accumulating the changes across periods,
starting from the actual balance at the report start date. This is starting from the actual balance at the report start date. This is
useful eg for a multi-period balance sheet, and when you are showing useful eg for a multi-period balance sheet, and when you are showing
only the data after a certain start date: only the data after a certain start date:
@ -1132,26 +1149,26 @@ COMMANDS
----------------------++------------------------------------- ----------------------++-------------------------------------
|| 0 0 0 || 0 0 0
Multi-column balance reports display accounts in flat mode by default; Multi-column balance reports display accounts in flat mode by default;
to see the hierarchy, use --tree. to see the hierarchy, use --tree.
With a reporting interval (like --quarterly above), the report With a reporting interval (like --quarterly above), the report
start/end dates will be adjusted if necessary so that they encompass start/end dates will be adjusted if necessary so that they encompass
the displayed report periods. This is so that the first and last peri- the displayed report periods. This is so that the first and last peri-
ods will be "full" and comparable to the others. ods will be "full" and comparable to the others.
The -E/--empty flag does two things in multicolumn balance reports: The -E/--empty flag does two things in multicolumn balance reports:
first, the report will show all columns within the specified report first, the report will show all columns within the specified report
period (without -E, leading and trailing columns with all zeroes are period (without -E, leading and trailing columns with all zeroes are
not shown). Second, all accounts which existed at the report start not shown). Second, all accounts which existed at the report start
date will be considered, not just the ones with activity during the date will be considered, not just the ones with activity during the
report period (use -E to include low-activity accounts which would oth- report period (use -E to include low-activity accounts which would oth-
erwise would be omitted). erwise would be omitted).
The -T/--row-total flag adds an additional column showing the total for The -T/--row-total flag adds an additional column showing the total for
each row. each row.
The -A/--average flag adds a column showing the average value in each The -A/--average flag adds a column showing the average value in each
row. row.
Here's an example of all three: Here's an example of all three:
@ -1173,13 +1190,13 @@ COMMANDS
# Average is rounded to the dollar here since all journal amounts are # Average is rounded to the dollar here since all journal amounts are
Budgets Budgets
With --budget and a report interval, all periodic transactions in your With --budget and a report interval, all periodic transactions in your
journal with that interval, active during the requested report period, journal with that interval, active during the requested report period,
are interpreted as recurring budget goals for the specified accounts are interpreted as recurring budget goals for the specified accounts
(and subaccounts), and the report will show the difference between (and subaccounts), and the report will show the difference between
actual and budgeted balances. actual and budgeted balances.
For example, you can take average monthly expenses in the common For example, you can take average monthly expenses in the common
expense categories to construct a minimal monthly budget: expense categories to construct a minimal monthly budget:
;; Budget ;; Budget
@ -1238,8 +1255,8 @@ COMMANDS
-----------------------++------------------------------------------------- -----------------------++-------------------------------------------------
|| 0 0 || 0 0
Accounts with no budget goals (not mentioned in the periodic transac- Accounts with no budget goals (not mentioned in the periodic transac-
tions) will be aggregated under <unbudgeted>, unless you add the tions) will be aggregated under <unbudgeted>, unless you add the
--show-unbudgeted flag to display them normally: --show-unbudgeted flag to display them normally:
$ hledger balance --budget --show-unbudgeted $ hledger balance --budget --show-unbudgeted
@ -1260,8 +1277,8 @@ COMMANDS
For more examples and details, see Budgeting and Forecasting. For more examples and details, see Budgeting and Forecasting.
Custom balance output Custom balance output
In simple (non-multi-column) balance reports, you can customise the You can customise the layout of simple (non-tabular) balance reports
output with --format FMT: with --format FMT:
$ hledger balance --format "%20(account) %12(total)" $ hledger balance --format "%20(account) %12(total)"
assets $-1 assets $-1
@ -1278,7 +1295,7 @@ COMMANDS
0 0
The FMT format string (plus a newline) specifies the formatting applied The FMT format string (plus a newline) specifies the formatting applied
to each account/balance pair. It may contain any suitable text, with to each account/balance pair. It may contain any suitable text, with
data fields interpolated like so: data fields interpolated like so:
%[MIN][.MAX](FIELDNAME) %[MIN][.MAX](FIELDNAME)
@ -1289,14 +1306,14 @@ COMMANDS
o FIELDNAME must be enclosed in parentheses, and can be one of: o FIELDNAME must be enclosed in parentheses, and can be one of:
o depth_spacer - a number of spaces equal to the account's depth, or o depth_spacer - a number of spaces equal to the account's depth, or
if MIN is specified, MIN * depth spaces. if MIN is specified, MIN * depth spaces.
o account - the account's name o account - the account's name
o total - the account's balance/posted total, right justified o total - the account's balance/posted total, right justified
Also, FMT can begin with an optional prefix to control how multi-com- Also, FMT can begin with an optional prefix to control how multi-com-
modity amounts are rendered: modity amounts are rendered:
o %_ - render on multiple lines, bottom-aligned (the default) o %_ - render on multiple lines, bottom-aligned (the default)
@ -1305,7 +1322,7 @@ COMMANDS
o %, - render on one line, comma-separated o %, - render on one line, comma-separated
There are some quirks. Eg in one-line mode, %(depth_spacer) has no There are some quirks. Eg in one-line mode, %(depth_spacer) has no
effect, instead %(account) has indentation built in. effect, instead %(account) has indentation built in.
Experimentation may be needed to get pleasing results. Experimentation may be needed to get pleasing results.
@ -1313,16 +1330,18 @@ COMMANDS
o %(total) - the account's total o %(total) - the account's total
o %-20.20(account) - the account's name, left justified, padded to 20 o %-20.20(account) - the account's name, left justified, padded to 20
characters and clipped at 20 characters characters and clipped at 20 characters
o %,%-50(account) %25(total) - account name padded to 50 characters, o %,%-50(account) %25(total) - account name padded to 50 characters,
total padded to 20 characters, with multiple commodities rendered on total padded to 20 characters, with multiple commodities rendered on
one line one line
o %20(total) %2(depth_spacer)%-(account) - the default format for the o %20(total) %2(depth_spacer)%-(account) - the default format for the
single-column balance report single-column balance report
This command also supports output destination and output formats.
Colour support Colour support
The balance command shows negative amounts in red, if: The balance command shows negative amounts in red, if:
@ -1330,23 +1349,6 @@ COMMANDS
o the output is not being redirected or piped anywhere o the output is not being redirected or piped anywhere
Output destination
The balance, print, register and stats commands can write their output
to a destination other than the console. This is controlled by the
-o/--output-file option.
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE
CSV output
The balance, print and register commands can write their output as CSV.
This is useful for exporting data to other applications, eg to make
charts in a spreadsheet. This is controlled by the -O/--output-format
option, or by specifying a .csv file extension with -o/--output-file.
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
balancesheet balancesheet
This command displays a simple balance sheet, showing historical ending This command displays a simple balance sheet, showing historical ending
balances of asset and liability accounts (ignoring any report begin balances of asset and liability accounts (ignoring any report begin
@ -1422,6 +1424,8 @@ COMMANDS
ancesheet shows historical ending balances, which is what you need for ancesheet shows historical ending balances, which is what you need for
a balance sheet; note this means it ignores report begin dates. a balance sheet; note this means it ignores report begin dates.
This command also supports output destination and output formats.
balancesheetequity balancesheetequity
Just like balancesheet, but also reports Equity (which it assumes is Just like balancesheet, but also reports Equity (which it assumes is
under a top-level equity account). under a top-level equity account).
@ -1519,6 +1523,8 @@ COMMANDS
though as with multicolumn balance reports you can alter the report though as with multicolumn balance reports you can alter the report
mode with --change/--cumulative/--historical. mode with --change/--cumulative/--historical.
This command also supports output destination and output formats.
check-dates check-dates
Check that transactions are sorted by increasing date. With a query, Check that transactions are sorted by increasing date. With a query,
only matched transactions' dates are checked. only matched transactions' dates are checked.
@ -1662,6 +1668,8 @@ COMMANDS
period, though as with multicolumn balance reports you can alter the period, though as with multicolumn balance reports you can alter the
report mode with --change/--cumulative/--historical. report mode with --change/--cumulative/--historical.
This command also supports output destination and output formats.
prices prices
Print all market prices from the journal. Print all market prices from the journal.
@ -1745,7 +1753,7 @@ COMMANDS
increasing dates, and that transactions on the same day do not get increasing dates, and that transactions on the same day do not get
reordered. See also the import command. reordered. See also the import command.
The print command also supports output destination and CSV output. This command also supports output destination and output formats.
Here's an example of print's CSV output: Here's an example of print's CSV output:
$ hledger print -Ocsv $ hledger print -Ocsv
@ -1899,12 +1907,11 @@ COMMANDS
$ hledger reg -w 100,40 # set overall width 100, description width 40 $ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width $ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
The register command also supports the -o/--output-file and -O/--out- This command also supports output destination and output formats.
put-format options for controlling output destination and CSV output.
register-match register-match
Print the one posting whose transaction description is closest to DESC, Print the one posting whose transaction description is closest to DESC,
in the style of the register command. Helps ledger-autosync detect in the style of the register command. Helps ledger-autosync detect
already-seen transactions when importing. already-seen transactions when importing.
rewrite rewrite
@ -1914,7 +1921,7 @@ COMMANDS
Show some journal statistics. Show some journal statistics.
-o FILE --output-file=FILE -o FILE --output-file=FILE
write output to FILE. A file extension matching one of the write output to FILE. A file extension matching one of the
above formats selects that format. above formats selects that format.
$ hledger stats $ hledger stats
@ -1929,12 +1936,11 @@ COMMANDS
Accounts : 8 (depth 3) Accounts : 8 (depth 3)
Commodities : 1 ($) Commodities : 1 ($)
The stats command displays summary information for the whole journal, The stats command displays summary information for the whole journal,
or a matched part of it. With a reporting interval, it shows a report or a matched part of it. With a reporting interval, it shows a report
for each report period. for each report period.
The stats command also supports -o/--output-file for controlling output This command also supports output destination and output formats.
destination.
tags tags
List all the tag names used in the journal. With a TAGREGEX argument, List all the tag names used in the journal. With a TAGREGEX argument,

View File

@ -36,7 +36,7 @@ Show accounts and their balances. Aliases: b, bal.
`-O FMT --output-format=FMT ` `-O FMT --output-format=FMT `
: select the output format. Supported formats: : select the output format. Supported formats:
txt, csv. txt, csv, html.
`-o FILE --output-file=FILE` `-o FILE --output-file=FILE`
: write output to FILE. A file extension matching one of the above formats selects that format. : write output to FILE. A file extension matching one of the above formats selects that format.
@ -336,8 +336,7 @@ For more examples and details, see [Budgeting and Forecasting](budgeting-and-for
### Custom balance output ### Custom balance output
In simple (non-multi-column) balance reports, you can customise the You can customise the layout of simple (non-tabular) balance reports with `--format FMT`:
output with `--format FMT`:
```shell ```shell
$ hledger balance --format "%20(account) %12(total)" $ hledger balance --format "%20(account) %12(total)"
@ -391,6 +390,8 @@ Some example formats:
- `%,%-50(account) %25(total)` - account name padded to 50 characters, total padded to 20 characters, with multiple commodities rendered on one line - `%,%-50(account) %25(total)` - account name padded to 50 characters, total padded to 20 characters, with multiple commodities rendered on one line
- `%20(total) %2(depth_spacer)%-(account)` - the default format for the single-column balance report - `%20(total) %2(depth_spacer)%-(account)` - the default format for the single-column balance report
This command also supports [output destination](/manual.html#output-destination) and [output formats](/manual.html#output-formats).
### Colour support ### Colour support
The balance command shows negative amounts in red, if: The balance command shows negative amounts in red, if:
@ -398,27 +399,4 @@ The balance command shows negative amounts in red, if:
- the `TERM` environment variable is not set to `dumb` - the `TERM` environment variable is not set to `dumb`
- the output is not being redirected or piped anywhere - the output is not being redirected or piped anywhere
### Output destination
The balance, print, register and stats commands can write their output to a
destination other than the console. This is controlled by the
`-o/--output-file` option.
```shell
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE
```
### CSV output
The balance, print and register commands can write their output as
CSV. This is useful for exporting data to other applications, eg to
make charts in a spreadsheet. This is controlled by the
`-O/--output-format` option, or by specifying a `.csv` file extension
with `-o/--output-file`.
```shell
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
```

View File

@ -250,6 +250,8 @@ Normally balancesheet shows historical ending balances, which is what
you need for a balance sheet; note this means it ignores report begin you need for a balance sheet; note this means it ignores report begin
dates. dates.
This command also supports [output destination](/manual.html#output-destination) and [output formats](/manual.html#output-formats).
## balancesheetequity ## balancesheetequity
Just like [balancesheet](#balancesheet), but also reports Equity Just like [balancesheet](#balancesheet), but also reports Equity
(which it assumes is under a top-level `equity` account). (which it assumes is under a top-level `equity` account).
@ -349,6 +351,8 @@ Normally cashflow shows changes in assets per period, though
as with [multicolumn balance reports](#multicolumn-balance-reports) as with [multicolumn balance reports](#multicolumn-balance-reports)
you can alter the report mode with `--change`/`--cumulative`/`--historical`. you can alter the report mode with `--change`/`--cumulative`/`--historical`.
This command also supports [output destination](/manual.html#output-destination) and [output formats](/manual.html#output-formats).
## check-dates ## check-dates
Check that transactions are sorted by increasing date. Check that transactions are sorted by increasing date.
With a query, only matched transactions' dates are checked. With a query, only matched transactions' dates are checked.
@ -499,6 +503,8 @@ Normally incomestatement shows revenues/expenses per period, though
as with [multicolumn balance reports](#multicolumn-balance-reports) as with [multicolumn balance reports](#multicolumn-balance-reports)
you can alter the report mode with `--change`/`--cumulative`/`--historical`. you can alter the report mode with `--change`/`--cumulative`/`--historical`.
This command also supports [output destination](/manual.html#output-destination) and [output formats](/manual.html#output-formats).
## prices ## prices
Print all [market prices](/manual#market-prices) from the journal. Print all [market prices](/manual#market-prices) from the journal.
@ -579,10 +585,7 @@ This assumes that transactions added to FILE always have same or increasing date
and that transactions on the same day do not get reordered. and that transactions on the same day do not get reordered.
See also the [import](#import) command. See also the [import](#import) command.
The print command also supports This command also supports [output destination](/manual.html#output-destination) and [output formats](/manual.html#output-formats).
[output destination](#output-destination)
and
[CSV output](#csv-output).
Here's an example of print's CSV output: Here's an example of print's CSV output:
```shell ```shell
$ hledger print -Ocsv $ hledger print -Ocsv
@ -737,9 +740,7 @@ $ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width $ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
``` ```
The register command also supports the This command also supports [output destination](/manual.html#output-destination) and [output formats](/manual.html#output-formats).
`-o/--output-file` and `-O/--output-format` options for controlling
[output destination](#output-destination) and [CSV output](#csv-output).
## register-match ## register-match
Print the one posting whose transaction description is closest to DESC, Print the one posting whose transaction description is closest to DESC,
@ -773,8 +774,7 @@ The stats command displays summary information for the whole journal, or
a matched part of it. With a [reporting interval](#reporting-interval), a matched part of it. With a [reporting interval](#reporting-interval),
it shows a report for each report period. it shows a report for each report period.
The stats command also supports `-o/--output-file` This command also supports [output destination](/manual.html#output-destination) and [output formats](/manual.html#output-formats).
for controlling [output destination](#output-destination).
## tags ## tags
List all the tag names used in the journal. With a TAGREGEX argument, List all the tag names used in the journal. With a TAGREGEX argument,

View File

@ -414,6 +414,28 @@ not [transaction prices](journal.html#transaction-prices) (unlike Ledger).
Using -B/--cost and -V/--value together is currently allowed, but the Using -B/--cost and -V/--value together is currently allowed, but the
results are probably not meaningful. Let us know if you find a use for this. results are probably not meaningful. Let us know if you find a use for this.
### Output destination
Some commands (print, register, stats, the balance commands)
can write their output to a destination other than the console.
This is controlled by the `-o/--output-file` option.
```shell
$ hledger balance -o - # write to stdout (the default)
$ hledger balance -o FILE # write to FILE
```
### Output format
Some commands can write their output in other formats.
Eg print and register can output CSV, and the balance commands can output CSV or HTML.
This is controlled by the `-O/--output-format` option, or by specifying a `.csv` or `.html` file extension with `-o/--output-file`.
```shell
$ hledger balance -O csv # write CSV to stdout
$ hledger balance -o FILE.csv # write CSV to FILE.csv
```
## Regular expressions ## Regular expressions
hledger uses [regular expressions](http://www.regular-expressions.info) in a number of places: hledger uses [regular expressions](http://www.regular-expressions.info) in a number of places: