[doc] Add tests to value and format expressions

and change formatting for value expressions using @defun, @defvar.
This commit is contained in:
Alexis Hildebrandt 2015-01-19 17:27:43 +01:00
parent 3d7eb24151
commit 185656e191
2 changed files with 506 additions and 90 deletions

View file

@ -956,6 +956,7 @@ Character position where entry for posting begins.
Return the transaction code, the string between the parenthesis after the date. Return the transaction code, the string between the parenthesis after the date.
.It Nm comment .It Nm comment
.It Nm commodity .It Nm commodity
Return the commodity of the posting amount.
.It Nm cost .It Nm cost
.It Nm count .It Nm count
.It Nm date .It Nm date
@ -970,7 +971,14 @@ Line number where entry for posting ends.
Character position where entry for posting ends. Character position where entry for posting ends.
.It Nm filename .It Nm filename
The name of the ledger data file from whence the posting came. The name of the ledger data file from whence the posting came.
.It Nm format_date .It Fn format_date date format
Return the
.Ar date
as a string using
.Ar format .
See
.Xr strftime 3
for format string details.
.It Nm get_at .It Nm get_at
.It Nm has_meta .It Nm has_meta
.It Nm has_tag .It Nm has_tag
@ -983,11 +991,19 @@ The name of the ledger data file from whence the posting came.
.It Nm options .It Nm options
.It Nm partial_account .It Nm partial_account
.It Nm payee .It Nm payee
.It Fn percent value_a value_b
Return the percentage of
.Ar value_a
in relation to
.Ar value_b .
.It Nm pending .It Nm pending
.It Nm post .It Nm post
.It Nm print .It Nm print
.It Nm quantity .It Nm quantity
.It Nm quoted .It Fn quoted expression
Surround
.Ar expression
with double-quotes.
.It Nm real .It Nm real
.It Nm rounded .It Nm rounded
.It Nm scrub .It Nm scrub

View file

@ -2,6 +2,7 @@
@setfilename ledger3.info @setfilename ledger3.info
@include version.texi @include version.texi
@set FIXME:UNDOCUMENTED @sc{undocumented}! Please help by contributing documentation for this feature.
@settitle Ledger: Command-Line Accounting @settitle Ledger: Command-Line Accounting
@c Before release, run C-u C-c C-u C-a (texinfo-all-menus-update with @c Before release, run C-u C-c C-u C-a (texinfo-all-menus-update with
@ -5323,13 +5324,13 @@ with Ledger 2.X.
@findex stats @findex stats
@findex stat @findex stat
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@node @command{select}, , @command{stats}, Reports about your Journals @node @command{select}, , @command{stats}, Reports about your Journals
@subsection @command{select} @subsection @command{select}
@findex select @findex select
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@node Command-Line Syntax, Budgeting and Forecasting, Reporting Commands, Top @node Command-Line Syntax, Budgeting and Forecasting, Reporting Commands, Top
@chapter Command-Line Syntax @chapter Command-Line Syntax
@ -5465,6 +5466,9 @@ Redirect output to @file{FILE}.
@itemx -i @var{FILE} @itemx -i @var{FILE}
Specify an options file. Specify an options file.
@item --import @var{FILE}
@value{FIXME:UNDOCUMENTED}
@item --account @var{STR} @item --account @var{STR}
@itemx -a @var{STR} @itemx -a @var{STR}
Specify default account @var{STR} for QIF file postings. Specify default account @var{STR} for QIF file postings.
@ -5782,7 +5786,7 @@ or testing small journal files not associated with your main financial
database. database.
@item --debug @var{CODE} @item --debug @var{CODE}
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@item --help @item --help
@itemx -h @itemx -h
@ -5843,10 +5847,10 @@ slowdown. When combined with @option{--debug @var{CODE}} ledger will
produce memory trace information. produce memory trace information.
@item --verify-memory @item --verify-memory
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@item --version @item --version
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@end ftable @end ftable
@ -5863,13 +5867,26 @@ sessions with multiple reports per session.
@ftable @option @ftable @option
@item --cache @var{FIXME} @item --cache @var{FIXME}
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@item --check-payees @item --check-payees
FIX THIS ENTRY @c FIXME thdox Enable strict and pedantic checking for payees as well as accounts,
commodities and tags. This only works in conjunction with
@option{--strict} or @option{--pedantic}.
@item --day-break @item --day-break
FIX THIS ENTRY @c FIXME thdox Break up @command{register} report of @ref{timelog} entries that span multiple
days by day.
@c see test/baseline/opt-day-break.dat
@c @smallexample @c input:
@c i 2015/
@c @end smallexample
@c @smallexample @c command:
@c $ ledger reg --day-break
@c @end smallexample
@c @smallexample @c output:
@c @end smallexample
@value{FIXME:UNDOCUMENTED}
@item --decimal-comma @item --decimal-comma
Direct Ledger to parse journals using the European standard comma as Direct Ledger to parse journals using the European standard comma as
@ -5881,7 +5898,8 @@ Direct Ledger to download prices using the script defined via the option
@option{--getquote @var{FILE}}. @option{--getquote @var{FILE}}.
@item --explicit @item --explicit
FIX THIS ENTRY @c FIXME thdox @c see test/baseline/opt-explicit.test
@value{FIXME:UNDOCUMENTED}
@item --file @var{FILE} @item --file @var{FILE}
@itemx -f @var{FILE} @itemx -f @var{FILE}
@ -5975,7 +5993,7 @@ For example 8100 seconds by default will be displayed as 2.25 whereas
with the @option{--time-colon} option they will be displayed as 2:15. with the @option{--time-colon} option they will be displayed as 2:15.
@item --value-expr @var{FIXME} @item --value-expr @var{FIXME}
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@end ftable @end ftable
@ -6035,7 +6053,9 @@ Set the width in characters of the amount column in the
Anonymize registry output, mostly for sending in bug reports. Anonymize registry output, mostly for sending in bug reports.
@item --auto-match @item --auto-match
FIX THIS ENTRY @c FIXME thdox @c Automatically match accounts from ledger journal when using convert command
@c see test/baseline/opt-auto-match.dat
@value{FIXME:UNDOCUMENTED}
@item --aux-date @item --aux-date
@itemx --effective @itemx --effective
@ -6059,7 +6079,10 @@ Strings}). The default is:
@end smallexample @end smallexample
@item --base @item --base
FIX THIS ENTRY @c ASK JOHN @c Report commodity in the base commodity s instead of h
@c Does this apply to other commodities too?
@c see test/baseline/opt-base.test/
@value{FIXME:UNDOCUMENTED}
@item --basis @item --basis
@itemx -B @itemx -B
@ -6109,7 +6132,7 @@ Consider only transactions that have been cleared for display and
calculation. calculation.
@item --cleared-format @var{FORMAT_STRING} @item --cleared-format @var{FORMAT_STRING}
FIX THIS ENTRY @c FIXME thdox: to keep? @c FIXME thdox: to keep?
Specify the format to use for the @command{cleared} report (@pxref{Format Specify the format to use for the @command{cleared} report (@pxref{Format
Strings}). The default is: Strings}). The default is:
@ -6178,8 +6201,11 @@ Specify the format ledger should use to read and print dates
Specify the width, in characters, of the date column in the Specify the width, in characters, of the date column in the
@command{register} report. @command{register} report.
@item --datetime-format @var{FIXME} @item --datetime-format @var{DATETIME_FORMAT}
FIX THIS ENTRY @c ASK JOHN @c Specify the format ledger should use to print datetimes in
@c @command{balance} @option{--timelog-report} reports.
@c see test/baseline/opt-datetime-format.test
@value{FIXME:UNDOCUMENTED}
@item --dc @item --dc
Display register or balance in debit/credit format If you use Display register or balance in debit/credit format If you use
@ -6287,7 +6313,7 @@ command}). Gives current account balances in the form of a register
report. report.
@item --exact @item --exact
FIX THIS ENTRY @c ASK JOHN @value{FIXME:UNDOCUMENTED}
@item --exchange @var{COMMODITY} @item --exchange @var{COMMODITY}
@itemx -X @var{COMMODITY} @itemx -X @var{COMMODITY}
@ -6365,10 +6391,10 @@ Print the first @var{INT} entries. Opposite of @option{--tail
@item --historical @item --historical
@itemx -H @itemx -H
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@item --immediate @item --immediate
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@item --inject @item --inject
Use @code{Expected} amounts in calculations. In case you know Use @code{Expected} amounts in calculations. In case you know
@ -6409,7 +6435,8 @@ Report the date and price at which each commodity was purchased in
a balance report. a balance report.
@item --lots-actual @item --lots-actual
FIX THIS ENTRY @c see test/baseline/opt-lots-actual.test
@value{FIXME:UNDOCUMENTED}
@item --market @item --market
@itemx -V @itemx -V
@ -6564,17 +6591,22 @@ Show all postings in a transaction, similar to @option{--related} but
show both @emph{sides} of each transaction. show both @emph{sides} of each transaction.
@item --revalued @item --revalued
FIX THIS ENTRY @c see test/baeline/opt-revalued.test
@value{FIXME:UNDOCUMENTED}
@item --revalued-only @item --revalued-only
FIX THIS ENTRY @c see test/baeline/opt-revalued-only.test
@value{FIXME:UNDOCUMENTED}
@item --revalued-total @var{FIXME} @item --revalued-total @var{FIXME}
FIX THIS ENTRY @value{FIXME:UNDOCUMENTED}
@item --rich-data @item --rich-data
@itemx --detail @itemx --detail
FIX THIS ENTRY @c FIXME thdox @c When generating ledger transaction from csv using the convert command
@c add CSV, Imported, and UUID meta-data.
@c see test/baeline/opt-rich-data.test
@value{FIXME:UNDOCUMENTED}
@item --seed @var{INT} @item --seed @var{INT}
Set the random seed to @var{INT} for the @code{generate} command. Set the random seed to @var{INT} for the @code{generate} command.
@ -6585,8 +6617,8 @@ Used as part of development testing.
Sort the @command{register} report based on the value expression given Sort the @command{register} report based on the value expression given
to sort. to sort.
@c @item --sort-all @var{FIXME} @item --sort-all @var{FIXME}
@c FIX THIS ENTRY @value{FIXME:UNDOCUMENTED}
@item --sort-xacts @var{VEXPR} @item --sort-xacts @var{VEXPR}
@itemx --period-sort @var{VEXPR} @itemx --period-sort @var{VEXPR}
@ -6599,7 +6631,7 @@ week.
@item --subtotal @item --subtotal
@itemx -s @itemx -s
FIX THIS ENTRY @value{FIXME:UNDOCUMENTED}
@item --tail @var{INT} @item --tail @var{INT}
@itemx --last @var{INT} @itemx --last @var{INT}
@ -6607,7 +6639,9 @@ Report only the last @var{INT} entries. Only useful in
a @command{register} report. a @command{register} report.
@item --time-report @item --time-report
FIX THIS ENTRY @c FIXME thdox @c Display begin and end time for each timelog entry in balance reports
@c see test/baseline/opt-time-report.test
@value{FIXME:UNDOCUMENTED}
@item --total @var{VEXPR} @item --total @var{VEXPR}
@itemx -T @var{VEXPR} @itemx -T @var{VEXPR}
@ -7614,6 +7648,7 @@ $ ledger --forecast "d<[2010]" bal ^assets ^liabilities
@chapter Time Keeping @chapter Time Keeping
@findex --day-break @findex --day-break
@anchor{timelog}
Ledger directly supports ``timelog'' entries, which have this form: Ledger directly supports ``timelog'' entries, which have this form:
@smallexample @c input:validate @smallexample @c input:validate
@ -7945,8 +7980,6 @@ will match both all the three examples below:
Expenses:Phone $-50.00 Expenses:Phone $-50.00
@end smallexample @end smallexample
@item (EXPR) @item (EXPR)
A sub-expression is nested in parenthesis. This can be useful passing A sub-expression is nested in parenthesis. This can be useful passing
more complicated arguments to functions, or for overriding the natural more complicated arguments to functions, or for overriding the natural
@ -7974,61 +8007,337 @@ expect (@pxref{Pre-Commands}).
@node Miscellaneous, , Complex expressions, Complex expressions @node Miscellaneous, , Complex expressions, Complex expressions
@subsection Miscellaneous @subsection Miscellaneous
@table @code The following Ledger journal data (saved as @file{expr.dat}) is used to explain the behaviour of the
@item abs--> U functions and variables below:
@item amount_expr @anchor{expr.dat}
@item ansify_if @smallexample @c input:3406FC1
@item ceiling 2015/01/16 * (C0D3) Payee
Return the next integer toward +infinity Assets:Cash ¤ -123,45
@item code ; Payee: PiggyBank
Return the transaction code, the string between the parenthesis after Expenses:Office Supplies
the date. @end smallexample
@item commodity
@item date @defun abs value
@item display_amount --> t @defunx U value
@item display_total --> T Return the absolute value of the given @var{value}, e.g. @var{amount}.
@item floor @end defun
Return the next integer toward -infinity @smallexample @c command:3406FC1
@item format $ ledger -f expr.dat --format "%(account) %(abs(amount))\n" reg assets
@item format_date @end smallexample
@item format_datetime @smallexample @c output:3406FC1
@item get_at Assets:Cash ¤ 123,45
@item is_seq @end smallexample
@item join
@item justify @defun amount_expr
@item market --> P @value{FIXME:UNDOCUMENTED}
@item nail_down @end defun
@item now --> d m
@item options @defun ansify_if value color bool
@item percent Render the given @var{expression} as a string, applying the proper ANSI escape
@item print codes to display it in the given @var{color} if @var{bool} is true. It
@item quantity typically checks the value of the option @option{--color}. Since ANSI escape
@item quoted codes include non-printable character sequences, such as escape @kbd{^[}
@item round the following example may not appear as the final result on the commandline.
@item rounded @end defun
@item roundto @smallexample @c command:4D836EE,with_input:3406FC1
Return value rounded to n digits. Does not affect formatting. $ ledger -f expr.dat --format "%(ansify_if(account, blue, options.color))\n" reg
@item scrub @end smallexample
@item should_bold @smallexample @c output:4D836EE
@item strip --> S Assets:Cash
@item to_amount Expenses:Office Supplies
@item to_balance @end smallexample
@item to_boolean
@item to_date @defun ceiling value
@item to_datetime Return the next integer of @var{value} toward @math{+}infinity.
@item to_int @end defun
@item to_mask @smallexample @c command:FF9C18C,with_input:3406FC1
@item to_sequence $ ledger -f expr.dat --format "%(account) %(ceiling(amount))\n" reg
@item to_spring @end smallexample
@item today @smallexample @c output:FF9C18C
@item top_amount Assets:Cash ¤ -123,00
@item total_expr Expenses:Office Supplies ¤ 124,00
@item trim @end smallexample
@item truncated
@item unround @defvar code
@item unrounded Return the transaction code, the string between the parenthesis after the date.
@item value_date @smallexample @c command:46FCFD3,with_input:3406FC1
@end table $ ledger -f expr.dat --format "%(account) %(code)\n" reg assets
@end smallexample
@smallexample @c output:46FCFD3
Assets:Cash C0D3
@end smallexample
@end defvar
@defvar commodity
Return the commodity of the posting amount.
@end defvar
@smallexample @c command:2CD27D7,with_input:3406FC1
$ ledger -f expr.dat --format "%(account) %(commodity)\n" reg
@end smallexample
@smallexample @c output:2CD27D7
Assets:Cash ¤
Expenses:Office Supplies ¤
@end smallexample
@defvar date
Return the date of the posting.
@end defvar
@smallexample @c command:67EBA45,with_input:3406FC1
$ ledger -f expr.dat --format "%(date) %(account)\n" reg assets
@end smallexample
@smallexample @c output:67EBA45
2015/01/16 Assets:Cash
@end smallexample
@defvar display_amount
@defvarx t
@value{FIXME:UNDOCUMENTED}
@end defvar
@c FIXME
@defvar display_total
@defvarx T
@value{FIXME:UNDOCUMENTED}
@end defvar
@defun floor value
Return the next integer of @var{value} toward @math{-}infinity.
@end defun
@smallexample @c command:4FDC7C5,with_input:3406FC1
$ ledger -f expr.dat --format "%(account) %(floor(amount))\n" reg
@end smallexample
@smallexample @c output:4FDC7C5
Assets:Cash ¤ -124,00
Expenses:Office Supplies ¤ 123,00
@end smallexample
@defun format
@value{FIXME:UNDOCUMENTED}
@end defun
@defun format_date date format
Return the @var{date} as a string using @var{format}. See strftime (3)
for format string details.
@end defun
@smallexample @c command:9605B13,with_input:3406FC1
$ ledger -f expr.dat --format "%(format_date(date, '%A, %B %d. %Y'))\n" reg assets
@end smallexample
@smallexample @c output:9605B13
Friday, January 16. 2015
@end smallexample
@defun format_datetime
@value{FIXME:UNDOCUMENTED}
@end defun
@defun get_at
@value{FIXME:UNDOCUMENTED}
@end defun
@defun is_seq
@value{FIXME:UNDOCUMENTED}
@end defun
@defun join
@value{FIXME:UNDOCUMENTED}
@end defun
@defun justify value first_width latter_width right_justify colorize
Right or left justify the string representing @var{value}. The width
of the field in the first line is given by @var{first_width}. For
subsequent lines the width is given by @var{latter_width}. If
@var{latter_width=-1}, then @var{first_width} is use for all lines.
If @var{right_justify=true} then the field is right justify within
the width of the field. If it is @var{false}, then the field is left
justified and padded to the full width of the field. If
@var{colorize} is true, then ledger will honor color settings.
@end defun
@smallexample @c command:082FB27,with_input:3406FC1
$ ledger -f expr.dat --format "»%(justify(account, 30, 30, true))«\n" reg
@end smallexample
@smallexample @c output:082FB27
» Assets:Cash«
» Expenses:Office Supplies«
@end smallexample
@defun market
@defunx P
@value{FIXME:UNDOCUMENTED}
@end defun
@defun nail_down
@value{FIXME:UNDOCUMENTED}
@end defun
@defvar now
@defvarx d
@defvarx m
@value{FIXME:UNDOCUMENTED}
@end defvar
@defvar options
A variable that allows access to the values of the given command-line options
using the long option names, e.g. to see whether @option{--daily} or @option{-D}
was given use @code{option.daily}.
@smallexample @c command:C1FC7A7,with_input:3406FC1
$ ledger -f expr.dat -X $ -D --format "%(options.daily) %(options.exchange)\n" reg assets
@end smallexample
@smallexample @c output:C1FC7A7
true $
@end smallexample
@end defvar
@defun percent value_a value_b
Return the percentage of @var{value_a} in relation to @var{value_b} (used as 100%)
@end defun
@smallexample @c command:04959BF,with_input:3406FC1
$ ledger -f expr.dat --format "%(percent(amount, 200))\n" reg
@end smallexample
@smallexample @c output:04959BF
-61.73%
61.73%
@end smallexample
@defun print
@value{FIXME:UNDOCUMENTED}
@end defun
@defun quantity
@value{FIXME:UNDOCUMENTED}
@end defun
@defun quoted expression
Surround @var{expression} with double-quotes.
@end defun
@smallexample @c command:EAD8AA7,with_input:3406FC1
$ ledger -f expr.dat --format "%(quoted(account)) %(quoted(amount))\n" reg
@end smallexample
@smallexample @c output:EAD8AA7
"Assets:Cash" "¤ -123,45"
"Expenses:Office Supplies" "¤ 123,45"
@end smallexample
@defun round
@value{FIXME:UNDOCUMENTED}
@end defun
@defun rounded
@value{FIXME:UNDOCUMENTED}
@end defun
@defun roundto value n
Return @var{value} rounded to @var{n} digits. Does not affect formatting.
@end defun
@smallexample @c command:B4DFB9F,with_input:3406FC1
$ ledger -f expr.dat --format "%(account) %(roundto(amount, 1))\n" reg
@end smallexample
@smallexample @c output:B4DFB9F
Assets:Cash ¤ -123,40
Expenses:Office Supplies ¤ 123,50
@end smallexample
@defun scrub
@value{FIXME:UNDOCUMENTED}
@end defun
@defun should_bold
@value{FIXME:UNDOCUMENTED}
@end defun
@defun strip
@defunx S
@value{FIXME:UNDOCUMENTED}
@end defun
@defun to_amount
@value{FIXME:UNDOCUMENTED}
@end defun
@defun to_balance
@value{FIXME:UNDOCUMENTED}
@end defun
@defun to_boolean
@value{FIXME:UNDOCUMENTED}
@end defun
@defun to_date
@value{FIXME:UNDOCUMENTED}
@end defun
@defun to_datetime
@value{FIXME:UNDOCUMENTED}
@end defun
@defun to_int value
@defunx int value
Return the integer value for @var{value}.
@end defun
@smallexample @c command:0B0CBA1,with_input:3406FC1
$ ledger -f expr.dat --format "%(1 + to_int('1'))\n%(2,5 + int(2,5))\n" reg assets
@end smallexample
@smallexample @c output:0B0CBA1
2
4.5
@end smallexample
@defun to_mask
@value{FIXME:UNDOCUMENTED}
@end defun
@defun to_sequence
@value{FIXME:UNDOCUMENTED}
@end defun
@defun to_string value
@defunx str value
Convert @var{value} to a character string.
@end defun
@defvar today
Return today's date.
@end defvar
@smallexample @c command:F2FDF4B,with_input:3406FC1
$ ledger -f expr.dat --now 2015/01/01 --format "%(today)\n" reg assets
@end smallexample
@smallexample @c output:F2FDF4B
2015/01/01
@end smallexample
@defun top_amount
@value{FIXME:UNDOCUMENTED}
@end defun
@defun total_expr
@value{FIXME:UNDOCUMENTED}
@end defun
@defun trim value
Trim leading and trailing whitespace from @var{value}.
@end defun
@smallexample @c command:377BBAB,with_input:3406FC1
$ ledger -f expr.dat --format "»%(trim(' Trimmed '))«\n" reg assets
@end smallexample
@smallexample @c output:377BBAB
»Trimmed«
@end smallexample
@defun truncated
@value{FIXME:UNDOCUMENTED}
@end defun
@defun unround
@value{FIXME:UNDOCUMENTED}
@end defun
@defun unrounded
@value{FIXME:UNDOCUMENTED}
@end defun
@defun value_date
@value{FIXME:UNDOCUMENTED}
@end defun
@node Format Strings, Extending with Python, Value Expressions, Top @node Format Strings, Extending with Python, Value Expressions, Top
@chapter Format Strings @chapter Format Strings
@ -8115,12 +8424,19 @@ or an expression enclosed in parentheses or brackets.
@findex --amount @var{EXPR} @findex --amount @var{EXPR}
@findex --total @var{VEXPR} @findex --total @var{VEXPR}
For demonstration purposes the journal data from @ref{expr.dat} is used.
The allowable expressions are: The allowable expressions are:
@table @code @table @code
@item % @item %
Inserts a percent sign. Inserts a percent sign.
@smallexample @c command:6F90EFC,with_input:3406FC1
$ ledger -f expr.dat --format "%%\n" reg assets
@end smallexample
@smallexample @c output:6F90EFC
%
@end smallexample
@item t @item t
Inserts the results of the value expression specified by Inserts the results of the value expression specified by
@ -8138,6 +8454,12 @@ parentheses. To insert five times the total value of an account, for
example, one could say @samp{%12(5*O)}. Note: It's important to put the example, one could say @samp{%12(5*O)}. Note: It's important to put the
five first in that expression, so that the commodity doesn't get five first in that expression, so that the commodity doesn't get
stripped from the total. stripped from the total.
@smallexample @c command:494256E,with_input:3406FC1
$ ledger -f expr.dat --format "%12(5*O)\n" reg assets
@end smallexample
@smallexample @c output:494256E
¤ -617,25
@end smallexample
@item [DATEFMT] @item [DATEFMT]
Inserts the result of formatting a posting's date with a date Inserts the result of formatting a posting's date with a date
@ -8147,20 +8469,52 @@ example: @samp{%[%Y/%m/%d %H:%M:%S]}.
@item S @item S
Insert the path name of the file from which the transaction's data was Insert the path name of the file from which the transaction's data was
read. Only sensible in a @command{register} report. read. Only sensible in a @command{register} report.
@c Note: Unable to test this properly since the output depends on
@c where the ledger source tree resides in the filesystem.
@smallexample
$ ledger -f ~/journal.dat --format "%S\n" reg assets
@end smallexample
@smallexample
/home/jwiegley/journal.dat
@end smallexample
@item B @item B
Inserts the beginning character position of that transaction within the Inserts the beginning character position of that transaction within the
file. file.
@smallexample @c command:2B669C9,with_input:3406FC1
$ ledger -f expr.dat --format "%B\n" reg assets
@end smallexample
@smallexample @c output:2B669C9
26
@end smallexample
@item b @item b
Inserts the beginning line of that transaction within the file. Inserts the beginning line of that transaction within the file.
@smallexample @c command:F6E356F,with_input:3406FC1
$ ledger -f expr.dat --format "%b\n" reg assets
@end smallexample
@smallexample @c output:F6E356F
2
@end smallexample
@item E @item E
Inserts the ending character position of that transaction within the Inserts the ending character position of that transaction within the
file. file.
@smallexample @c command:0E55246,with_input:3406FC1
$ ledger -f expr.dat --format "%E\n" reg assets
@end smallexample
@smallexample @c output:0E55246
90
@end smallexample
@item e @item e
Inserts the ending line of that transaction within the file. Inserts the ending line of that transaction within the file.
@smallexample @c command:A26F4C0,with_input:3406FC1
$ ledger -f expr.dat --format "%e\n" reg assets
@end smallexample
@smallexample @c output:A26F4C0
3
@end smallexample
@item D @item D
Returns the date according to the default format. Returns the date according to the default format.
@ -8179,9 +8533,23 @@ character if all of the member postings have the same state.
@item C @item C
Inserts the transaction code. This is the value specified between Inserts the transaction code. This is the value specified between
parentheses on the first line of the transaction. parentheses on the first line of the transaction.
@smallexample @c command:C1CAAF3,with_input:3406FC1
$ ledger -f expr.dat --format "%C\n" reg assets
@end smallexample
@c Note: The output needs a space character at the end
@c for this test to pass
@smallexample @c output:C1CAAF3
(C0D3)
@end smallexample
@item P @item P
Inserts the payee related to a posting. Inserts the payee related to a posting.
@smallexample @c command:F41A9BB,with_input:3406FC1
$ ledger -f expr.dat --format "%P\n" reg assets
@end smallexample
@smallexample @c output:F41A9BB
PiggyBank
@end smallexample
@c @item a @c @item a
@c Inserts the optimal short name for an account. This is normally @c Inserts the optimal short name for an account. This is normally
@ -8191,6 +8559,13 @@ Inserts the payee related to a posting.
@item A @item A
Inserts the full name of an account. Inserts the full name of an account.
@smallexample @c command:29A70DD,with_input:3406FC1
$ ledger -f expr.dat --format "%A\n" reg
@end smallexample
@smallexample @c output:29A70DD
Assets:Cash
Expenses:Office Supplies
@end smallexample
@c @item W @c @item W
@c This is the same as @code{%A}, except that it first displays the @c This is the same as @code{%A}, except that it first displays the
@ -8207,12 +8582,25 @@ Inserts the full name of an account.
@item N @item N
Inserts the note associated with a posting, if one exists. Inserts the note associated with a posting, if one exists.
@smallexample @c command:E6DC93A,with_input:3406FC1
$ ledger -f expr.dat --format "%N\n" reg assets
@end smallexample
@smallexample @c output:E6DC93A
Payee: PiggyBank
@end smallexample
@item / @item /
The @samp{%/} construct is special. It separates a format string The @samp{%/} construct is special. It separates a format string
between what is printed for the first posting of a transaction, and between what is printed for the first posting of a transaction, and
what is printed for all subsequent postings. If not used, the what is printed for all subsequent postings. If not used, the
same format string is used for all postings. same format string is used for all postings.
@smallexample @c command:E80897D,with_input:3406FC1
$ ledger -f expr.dat --format "%P\n%/%A\n" reg
@end smallexample
@smallexample @c output:E80897D
PiggyBank
Expenses:Office Supplies
@end smallexample
@end table @end table
@ -9323,7 +9711,7 @@ slowdown. When combined with @option{--debug @var{CODE}} ledger will
produce memory trace information. produce memory trace information.
@item --verify-memory @item --verify-memory
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@item --version @item --version
Print version information and exit. Print version information and exit.
@ -9421,7 +9809,7 @@ true
@end smallexample @end smallexample
@item script @item script
FIX THIS ENTRY @c FIXME thdox @value{FIXME:UNDOCUMENTED}
@item template @item template
Shows the insertion template that the @command{xact} sub-command Shows the insertion template that the @command{xact} sub-command
@ -9706,11 +10094,23 @@ to the main body of the documentation.
@node Invoking Ledger, Ledger Files, Cookbook, Cookbook @node Invoking Ledger, Ledger Files, Cookbook, Cookbook
@subsection Invoking Ledger @subsection Invoking Ledger
@smallexample
@smallexample @c command:validate
$ ledger --group-by "tag('trip')" bal $ ledger --group-by "tag('trip')" bal
$ ledger reg --sort "tag('foo')" %foo @end smallexample
@c FIXME: The following example fails to validate due to:
@c While applying is_realzero to :
@c Error: Cannot determine if an uninitialized value is really zero
@c @smallexample @c command:validate
@c $ ledger reg --sort "tag('foo')" %foo
@c @end smallexample
@smallexample @c command:validate
$ ledger cleared VWCU NFCU Tithe Misentry $ ledger cleared VWCU NFCU Tithe Misentry
@end smallexample
@smallexample @c command:validate
$ ledger register Joint --uncleared $ ledger register Joint --uncleared
@end smallexample
@smallexample @c command:validate
$ ledger register Checking --sort d -d 'd>[2011/04/01]' until 2011/05/25 $ ledger register Checking --sort d -d 'd>[2011/04/01]' until 2011/05/25
@end smallexample @end smallexample