diff --git a/hledger-ui/doc/hledger-ui.1 b/hledger-ui/doc/hledger-ui.1 index a512081a5..51953c2f5 100644 --- a/hledger-ui/doc/hledger-ui.1 +++ b/hledger-ui/doc/hledger-ui.1 @@ -19,6 +19,7 @@ hledger is a cross\-platform program for tracking money, time, or any other commodity, using double\-entry accounting and a simple, editable file format. hledger is inspired by and largely compatible with ledger(1). +.PP hledger\-ui is hledger\[aq]s curses\-style interface. It reads a hledger journal file .PP diff --git a/hledger-ui/doc/hledger-ui.1.txt b/hledger-ui/doc/hledger-ui.1.txt index 33d198bc0..c4e4e7335 100644 --- a/hledger-ui/doc/hledger-ui.1.txt +++ b/hledger-ui/doc/hledger-ui.1.txt @@ -14,8 +14,10 @@ DDEESSCCRRIIPPTTIIOONN hledger is a cross-platform program for tracking money, time, or any other commodity, using double-entry accounting and a simple, editable file format. hledger is inspired by and largely compatible with - ledger(1). hledger-ui is hledger's curses-style interface. It reads a - hledger journal file + ledger(1). + + hledger-ui is hledger's curses-style interface. It reads a hledger + journal file (~/.hledger.journal, $LEDGER_FILE, or -f FILE; see hledger(1) or hledger_journal(5)) diff --git a/hledger/doc/commands-balance.m4.md b/hledger/doc/commands-balance.m4.md index 1a687af74..0a4803e2f 100644 --- a/hledger/doc/commands-balance.m4.md +++ b/hledger/doc/commands-balance.m4.md @@ -44,7 +44,7 @@ txt, csv. The balance command displays accounts and balances. It is hledger's most featureful and most useful command. -``` {.shell .right} +```shell $ hledger balance $-1 assets $1 bank:saving @@ -76,30 +76,34 @@ balances of any subaccounts. Accounts which have zero balance (and no non-zero subaccounts) are omitted. Use `-E/--empty` to show them. -``` {.shell .right .clear} +A final total is displayed by default; use `-N/--no-total` to suppress it: + +```shell $ hledger balance -p 2008/6 expenses --no-total $2 expenses $1 food $1 supplies ``` -A final total is displayed by default; use `-N/--no-total` to suppress it. - ### Flat mode -``` {.shell .right} -$ hledger balance -p 2008/6 expenses -N --flat --drop 1 - $1 food - $1 supplies -``` - To see a flat list of full account names instead of the default hierarchical display, use `--flat`. In this mode, accounts (unless depth-clipped) show their "exclusive" balance, excluding any subaccount balances. In this mode, you can also use `--drop N` to omit the first few account name components. +```shell +$ hledger balance -p 2008/6 expenses -N --flat --drop 1 + $1 food + $1 supplies +``` + ### Depth limiting -``` {.shell .right} +With `--depth N`, balance shows accounts only to the specified depth. +This is very useful to show a complex charts of accounts in less detail. +In flat mode, balances from accounts below the depth limit will be shown as part of a parent account at the depth limit. + +```shell $ hledger balance -N --depth 1 $-1 assets $2 expenses @@ -107,10 +111,6 @@ $ hledger balance -N --depth 1 $1 liabilities ``` -With `--depth N`, balance shows accounts only to the specified depth. -This is very useful to show a complex charts of accounts in less detail. -In flat mode, balances from accounts below the depth limit will be shown as part of a parent account at the depth limit. - ### Multicolumn balance reports @@ -119,24 +119,9 @@ With a [reporting interval](#reporting-interval), multiple balance columns will be shown, one for each report period. There are three types of multi-column balance report, showing different information: -``` {.shell .right} -$ hledger balance --quarterly income expenses -E -Balance changes in 2008: - - || 2008q1 2008q2 2008q3 2008q4 -===================++================================= - expenses:food || 0 $1 0 0 - expenses:supplies || 0 $1 0 0 - income:gifts || 0 $-1 0 0 - income:salary || $-1 0 0 0 --------------------++--------------------------------- - || $-1 $1 0 0 - -``` - 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 -for a monthly income statement. +for a monthly income statement: -
-``` {.shell .right} -$ hledger balance --quarterly income expenses -E --cumulative -Ending balances (cumulative) in 2008: + ```shell + $ hledger balance --quarterly income expenses -E + Balance changes in 2008: - || 2008/03/31 2008/06/30 2008/09/30 2008/12/31 -===================++================================================= - expenses:food || 0 $1 $1 $1 - expenses:supplies || 0 $1 $1 $1 - income:gifts || 0 $-1 $-1 $-1 - income:salary || $-1 $-1 $-1 $-1 --------------------++------------------------------------------------- - || $-1 0 0 0 + || 2008q1 2008q2 2008q3 2008q4 + ===================++================================= + expenses:food || 0 $1 0 0 + expenses:supplies || 0 $1 0 0 + income:gifts || 0 $-1 0 0 + income:salary || $-1 0 0 0 + -------------------++--------------------------------- + || $-1 $1 0 0 -``` + ``` 2. With `--cumulative`: each column shows the ending balance for that period, accumulating the changes across periods, starting from 0 at -the report start date. This mode is not often used. +the report start date: - -``` {.shell .right} -$ hledger balance ^assets ^liabilities -Q -Balance changes in 2008: + ```shell + $ hledger balance --quarterly income expenses -E --cumulative + Ending balances (cumulative) in 2008: - || 2008q1 2008q2 2008q3 2008q4 -======================++================================= - assets:bank:checking || $1 0 0 $-1 - assets:bank:saving || 0 $1 0 0 - assets:cash || 0 $-2 0 0 - liabilities:debts || 0 0 0 $1 -----------------------++--------------------------------- - || $1 $-1 0 0 + || 2008/03/31 2008/06/30 2008/09/30 2008/12/31 + ===================++================================================= + expenses:food || 0 $1 $1 $1 + expenses:supplies || 0 $1 $1 $1 + income:gifts || 0 $-1 $-1 $-1 + income:salary || $-1 $-1 $-1 $-1 + -------------------++------------------------------------------------- + || $-1 0 0 0 -$ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1 -Ending balances (historical) in 2008/04/01-2008/12/31: - - || 2008/06/30 2008/09/30 2008/12/31 -======================++===================================== - assets:bank:checking || $1 $1 0 - assets:bank:saving || $1 $1 $1 - assets:cash || $-2 $-2 $-2 - liabilities:debts || 0 0 $1 -----------------------++------------------------------------- - || 0 0 0 - -``` + ``` 3. With `--historical/-H`: each column shows the actual historical ending balance for that period, accumulating the changes across periods, 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 only the data after a certain start date. +you are showing only the data after a certain start date: - -``` {.shell .right} -$ hledger balance -Q income expenses --tree -E -TA + ```shell + $ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1 + Ending balances (historical) in 2008/04/01-2008/12/31: + + || 2008/06/30 2008/09/30 2008/12/31 + ======================++===================================== + assets:bank:checking || $1 $1 0 + assets:bank:saving || $1 $1 $1 + assets:cash || $-2 $-2 $-2 + liabilities:debts || 0 0 $1 + ----------------------++------------------------------------- + || 0 0 0 + + ``` + +Multi-column balance reports display accounts in flat mode by default; +to see the hierarchy, use `--tree`. + +With a reporting interval (like `--quarterly` above), the report +start/end dates will be adjusted if necessary so that they encompass +the displayed report periods. This is so that the first and last +periods will be "full" and comparable to the others. + +The `-E/--empty` flag does two things in multicolumn balance reports: +first, the report will show all columns within the specified report +period (without -E, leading and trailing columns with all zeroes are +not shown). Second, all accounts which existed at the report start +date will be considered, not just the ones with activity during the +report period (use -E to include low-activity accounts which would +otherwise would be omitted). + +The `-T/--row-total` flag adds an additional column showing the total +for each row. + +The `-A/--average` flag adds a column showing the average value in +each row. + +Here's an example of all three: + +```shell +$ hledger balance -Q income expenses --tree -ETA Balance changes in 2008: || 2008q1 2008q2 2008q3 2008q4 Total Average @@ -221,27 +230,6 @@ Balance changes in 2008: ``` -Multi-column balance reports display accounts in flat mode by default; -to see the hierarchy, use `--tree`. - -Note that with a reporting interval, the report start/end dates will -be "enlarged" if necessary so that they encompass the displayed report -periods. This is so that the first and last periods will be "full" and -comparable to the others. - -The `-E/--empty` flag does two things here: first, the report will -show all columns within the specified report period (without -E, -leading and trailing columns with all zeroes are not shown). Second, -all accounts which existed at the report start date will be -considered, not just the ones with activity during the report period -(use -E to include low-activity accounts which would otherwise would -be omitted). - -The `-T/--row-total` flag adds an additional column showing the total -for each row. The `-A/--average` flag adds a column showing the -average value in each row. Note in `--H/--historical` mode only the -average is useful, and in `--cumulative` mode neither is useful. - ### Market value The `-V/--value` flag converts all the reported amounts to their @@ -254,15 +242,12 @@ Unlike Ledger, hledger's -V only uses the market prices recorded with P directives, ignoring transaction prices recorded as part of posting amounts (which -B/--cost uses). Using -B and -V together is allowed. - - ### Custom balance output -``` {.shell .right} +In simple (non-multi-column) balance reports, you can customise the +output with `--format FMT`: + +```shell $ hledger balance --format "%20(account) %12(total)" assets $-1 bank:saving $1 @@ -278,65 +263,62 @@ $ hledger balance --format "%20(account) %12(total)" 0 ``` -In simple (non-multi-column) balance reports, you can customise the -output with `--format FMT`. FMT (plus a newline) will be displayed for -each account/balance pair. It is a format string with data fields -interpolated by +The FMT format string (plus a newline) specifies the formatting +applied to each account/balance pair. It may contain any suitable +text, with data fields interpolated like so: `%[MIN][.MAX](FIELDNAME)` -where MIN means pad with spaces to at least this width, and MAX means -truncate at this width. The field name must be enclosed in -parentheses. Three fields are available: +- MIN pads with spaces to at least this width (optional) +- MAX truncates at this width (optional) +- FIELDNAME must be enclosed in parentheses, and can be one of: -- `depth_spacer` - a number of spaces equal to the account's depth, or if MIN is specified, MIN * depth spaces. -- `account` - the account's name -- `total` - the account's balance/posted total, right justified + - `depth_spacer` - a number of spaces equal to the account's depth, or if MIN is specified, MIN * depth spaces. + - `account` - the account's name + - `total` - the account's balance/posted total, right justified -When the total has multiple commodities, by default each commodity is -displayed on a separate line, and the report item will be bottom -aligned. You can change how such multi-line values are rendered by -beginning the format with a special prefix: +Also, FMT can begin with an optional prefix to control how +multi-commodity amounts are rendered: - `%_` - render on multiple lines, bottom-aligned (the default) - `%^` - render on multiple lines, top-aligned -- `%,` - render on one line, with multi-line values comma-separated +- `%,` - render on one line, comma-separated -There are some quirks, and experimentation may be needed to get pleasing output. -In one-line mode, `%(depth_spacer)` has no effect, instead `%(account)` has indentation built in. +There are some quirks. Eg in one-line mode, `%(depth_spacer)` has no +effect, instead `%(account)` has indentation built in. +Experimentation may be needed to get pleasing results. -Examples: +Some example formats: - `%(total)` - the account's total - `%-20.20(account)` - the account's name, left justified, padded to 20 characters and clipped at 20 characters -- `%20(total) %2(depth_spacer)%-(account)` - default format for the single-column balance report - `%,%-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 ### Output destination -```{.shell .bold .right} -$ hledger balance -o - # write to stdout (the default) -$ hledger balance -o FILE # write to FILE -``` - 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. -### CSV output - -```{.shell .bold .right} -$ hledger balance -O csv # write CSV to stdout -$ hledger balance -o FILE.csv # write CSV to FILE.csv +```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 +``` diff --git a/hledger/doc/commands.m4.md b/hledger/doc/commands.m4.md index d259e2b4f..d7acfb283 100644 --- a/hledger/doc/commands.m4.md +++ b/hledger/doc/commands.m4.md @@ -13,6 +13,7 @@ command name (`hledger inc`), or one of the standard short aliases displayed in the command list (`hledger is`). --- +# comment: # for each command: name, synopsis, description, examples. ... @@ -90,15 +91,13 @@ The activity command displays an ascii histogram showing transaction counts by day, week, month or other reporting interval (by day is the default). With query arguments, it counts only matched transactions. -_col3_({{ -_shell_({{ +```shell $ hledger activity --quarterly 2008-01-01 ** 2008-04-01 ******* 2008-07-01 2008-10-01 ** -}}) -}}) +``` ## add Prompt for transactions and add them to the journal. @@ -178,8 +177,7 @@ This command displays a simple assumes that you have top-level accounts named `asset` and `liability` (plural forms also allowed.) -_col3_({{ -_shell_({{ +```shell $ hledger balancesheet Balance Sheet @@ -198,8 +196,7 @@ Liabilities: Total: -------------------- 0 -}}) -}}) +``` ## cashflow Show a cashflow statement. Alias: cf. @@ -217,8 +214,7 @@ period. It currently assumes that cash accounts are under a top-level account named `asset` and do not contain `receivable` or `A/R` (plural forms also allowed.) -_col3_({{ -_shell_({{ +```shell $ hledger cashflow Cashflow Statement @@ -232,8 +228,7 @@ Cash flows: Total: -------------------- $-1 -}}) -}}) +``` ## help Show detailed help. @@ -280,8 +275,7 @@ This command displays a simple currently assumes that you have top-level accounts named `income` (or `revenue`) and `expense` (plural forms also allowed.) -_col3_({{ -_shell_({{ +```shell $ hledger incomestatement Income Statement @@ -302,8 +296,7 @@ Expenses: Total: -------------------- 0 -}}) -}}) +``` ## print Show transactions from the journal. @@ -318,21 +311,7 @@ Show transactions from the journal. : select the output format. Supported formats: txt, csv. -The print command displays full transactions from the journal file, -tidily formatted and showing all amounts explicitly. The output of -print is always a valid hledger journal, but it does always not -preserve all original content exactly (eg directives). - -hledger's print command also shows all unit prices in effect, or (with --B/--cost) shows cost amounts. - -The print command also supports -[output destination](#output-destination) -and -[CSV output](#csv-output). - -_col3_({{ -_shell_({{ +```shell $ hledger print 2008/01/01 income assets:bank:checking $1 @@ -354,9 +333,20 @@ $ hledger print 2008/12/31 * pay off liabilities:debts $1 assets:bank:checking $-1 +``` -}}) -}}) +The print command displays full transactions from the journal file, +tidily formatted and showing all amounts explicitly. The output of +print is always a valid hledger journal, but it does always not +preserve all original content exactly (eg directives). + +hledger's print command also shows all unit prices in effect, or (with +-B/--cost) shows cost amounts. + +The print command also supports +[output destination](#output-destination) +and +[CSV output](#csv-output). ## register Show postings and their running total. Alias: reg. @@ -380,7 +370,11 @@ Show postings and their running total. Alias: reg. : select the output format. Supported formats: txt, csv. -```{.shell .right} +The register command displays postings, one per line, and their +running total. This is typically used with a [query](#queries) +selecting a particular account, to see that account's activity: + +```shell $ hledger register checking 2008/01/01 income assets:bank:checking $1 $1 2008/06/01 gift assets:bank:checking $1 $2 @@ -388,21 +382,17 @@ $ hledger register checking 2008/12/31 pay off assets:bank:checking $-1 0 ``` -The register command displays postings, one per line, and their -running total. This is typically used with a [query](#queries) -selecting a particular account, to see that account's activity. +The `--historical`/`-H` flag adds the balance from any undisplayed +prior postings to the running total. This is useful when you want to +see only recent activity, with a historically accurate running balance: -```{.shell .right .clear} +```shell $ hledger register checking -b 2008/6 --historical 2008/06/01 gift assets:bank:checking $1 $2 2008/06/02 save assets:bank:checking $-1 $1 2008/12/31 pay off assets:bank:checking $-1 0 ``` -The `--historical`/`-H` flag adds the balance from any prior postings -to the running total, to show the actual historical running balance. -This is useful when you want to see just the recent activity. - The `--depth` option limits the amount of sub-account detail displayed. The `--average`/`-A` flag shows the running average posting amount @@ -413,12 +403,18 @@ It works best when showing just one account and one commodity. The `--related`/`-r` flag shows the *other* postings in the transactions of the postings which would normally be shown. -```{.shell .right} +With a [reporting interval](#reporting-interval), register shows +summary postings, one per interval, aggregating the postings to each account: + +```shell $ hledger register --monthly income 2008/01 income:salary $-1 $-1 2008/06 income:gifts $-1 $-2 ``` -```{.shell .right} +Periods with no activity, and summary postings with a zero amount, are +not shown by default; use the `--empty`/`-E` flag to see them: + +```shell $ hledger register --monthly income -E 2008/01 income:salary $-1 $-1 2008/02 0 $-1 @@ -433,22 +429,17 @@ $ hledger register --monthly income -E 2008/11 0 $-2 2008/12 0 $-2 ``` -```{.shell .right .clear} -$ hledger register --monthly assets --depth 1 # cashflow (changes to assets) by month + +Often, you'll want to see just one line per interval. +The `--depth` option helps with this, causing subaccounts to be aggregated: + +```shell +$ hledger register --monthly assets --depth 1h 2008/01 assets $1 $1 2008/06 assets $-1 0 2008/12 assets $-1 $-1 ``` -With a [reporting interval](#reporting-interval), register shows -summary postings, one per interval, aggregating the postings to each account. - -Periods with no activity, and summary postings with a zero amount, are -not shown by default; use the `--empty`/`-E` flag to see them. - -Often, you'll want to see just one line per interval. -The `--depth` option helps with this, causing subaccounts to be aggregated. - Note when using report intervals, if you specify start/end dates these will be adjusted outward if necessary to contain a whole number of intervals. This ensures that the first and last intervals are full @@ -470,13 +461,13 @@ date (10) description (D) account (W-41-D) amount (12) balance (12) DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA ``` and some examples: -```{.shell .bold} -$ hledger reg # use terminal width (or 80 on windows) -$ hledger reg -w 100 # use width 100 -$ COLUMNS=100 hledger reg # set with one-time environment variable -$ 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 $COLUMNS,40 # use terminal width, and set description width +```shell +$ hledger reg # use terminal width (or 80 on windows) +$ hledger reg -w 100 # use width 100 +$ COLUMNS=100 hledger reg # set with one-time environment variable +$ 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 $COLUMNS,40 # use terminal width, and set description width ``` The register command also supports the @@ -489,7 +480,7 @@ Show some journal statistics. `-o FILE[.FMT] --output-file=FILE[.FMT]` : write output to FILE instead of stdout. A recognised FMT suffix influences the format. -```{.shell .right} +```shell $ hledger stats Main journal file : /src/hledger/data/sample.journal Included journal files : @@ -513,7 +504,7 @@ for controlling [output destination](#output-destination). ## test Run built-in unit tests. -```{.shell .right} +```shell $ hledger test Cases: 74 Tried: 74 Errors: 0 Failures: 0 ``` @@ -553,7 +544,7 @@ Web API server, see [hledger-api](hledger-api.html). ## autosync Download OFX bank data and/or convert OFX to hledger journal format. -``` {.shell .right} +```shell $ hledger autosync --help usage: hledger-autosync [-h] [-m MAX] [-r] [-a ACCOUNT] [-l LEDGER] [-i INDENT] [--initial] [--fid FID] [--assertions] [-d] [--hledger] @@ -617,7 +608,7 @@ download. ## diff Show transactions present in one journal file but not another -```{.shell .right} +```shell $ hledger diff --help Usage: hledger-diff account:name left.journal right.journal $ cat a.journal @@ -649,7 +640,7 @@ journals with bank statements. ## equity Print a journal entry that resets account balances to zero. -```{.shell .right} +```shell $ hledger balance --flat -E assets liabilities 0 assets:bank:checking $1 assets:bank:saving @@ -687,7 +678,7 @@ just one file, or on several files concatenated with [include](#include). ## interest Generate interest transactions. -```{.shell .right} +```shell $ hledger interest --help Usage: hledger-interest [OPTION...] ACCOUNT -h --help print this message and exit @@ -708,7 +699,7 @@ Usage: hledger-interest [OPTION...] ACCOUNT --ing-diba compute interest according for Ing-Diba Tagesgeld account ``` -```{.shell .right .clear} +```shell $ cat interest.journal 2008/09/26 Loan Assets:Bank EUR 10000.00 @@ -727,7 +718,7 @@ $ cat interest.journal Liabilities:Bank ``` -```{.shell .right .clear} +```shell $ hledger interest -- -f interest.journal --source=Expenses:Interest \ --target=Liabilities:Bank --30-360 --annual=0.05 Liabilities:Bank 2008/09/26 Loan @@ -779,7 +770,7 @@ with a fixed rate and the scheme mandated by the German BGB288 ## irr Calculate internal rate of return. -```{.shell .right} +```shell $ hledger irr --help Usage: hledger-irr [OPTION...] -h --help print this message and exit @@ -796,7 +787,7 @@ Usage: hledger-irr [OPTION...] -Y --yearly calculate interest for each year ``` -```{.shell .right .clear} +```shell $ cat irr.journal 2011-01-01 Some wild speculation – I wonder if it pays off Speculation €100.00 @@ -828,7 +819,7 @@ $ cat irr.journal Rate Gain -€ 5.00 ``` -```{.shell .right .clear} +```shell $ hledger-irr -f irr.journal -t "Rate Gain" -i Speculation --monthly 2011/01/01 - 2011/02/01: 12.49% 2011/02/01 - 2011/03/01: 41.55% @@ -848,7 +839,7 @@ See the package page for more. ## print-unique Print only only journal entries which have a unique description. -```{.shell .right} +```shell $ cat unique.journal 1/1 test (acct:one) 1 @@ -864,7 +855,7 @@ $ LEDGER_FILE=unique.journal hledger print-unique ## rewrite Prints all journal entries, adding specified custom postings to matched entries. -```{.shell .right .bold} +```shell $ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ... $ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33' $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"' diff --git a/hledger/doc/examples.m4.md b/hledger/doc/examples.m4.md index 13336e214..ad8e0b9a5 100644 --- a/hledger/doc/examples.m4.md +++ b/hledger/doc/examples.m4.md @@ -24,6 +24,7 @@ $ hledger print expenses:food $10 assets:cash $-10 ``` + ```shell $ hledger accounts --tree assets @@ -33,6 +34,7 @@ expenses income gifts ``` + ```shell $ hledger balance $10 assets:cash @@ -41,13 +43,16 @@ $ hledger balance -------------------- 0 ``` + ```shell $ hledger register cash 2015/09/30 gift received assets:cash $20 $20 2015/10/16 farmers market assets:cash $-10 $10 ``` -```{.shell .bold} +More commands: + +```shell $ hledger # show available commands $ hledger add # add more transactions to the journal file $ hledger balance # all accounts with aggregated balances diff --git a/hledger/doc/hledger.1 b/hledger/doc/hledger.1 index 874c71e6b..d9de53de2 100644 --- a/hledger/doc/hledger.1 +++ b/hledger/doc/hledger.1 @@ -125,6 +125,8 @@ $\ hledger\ register\ cash 2015/10/16\ farmers\ market\ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-10\ \ \ \ \ \ \ \ \ \ \ $10 \f[] .fi +.PP +More commands: .IP .nf \f[C] @@ -324,10 +326,10 @@ Examples: .PP .TS tab(@); -lw(33.7n) lw(36.3n). +l l. T{ \f[C]2009/1/1\f[], \f[C]2009/01/01\f[], \f[C]2009\-1\-1\f[], -\f[C]2009.1.1\f[] \ +\f[C]2009.1.1\f[] T}@T{ simple dates, several separators allowed T} @@ -394,58 +396,97 @@ hledger\[aq]s period expressions are similar to Ledger\[aq]s, though not identical. Here\[aq]s a basic period expression specifying the first quarter of 2009. -Note hledger always treats start dates as inclusive and end dates as +Note, hledger always treats start dates as inclusive and end dates as exclusive: -.IP -.nf -\f[C] -\-p\ "from\ 2009/1/1\ to\ 2009/4/1" -\f[] -.fi .PP -Keywords like "from" and "to" are optional, and so are the spaces. -Just don\[aq]t run two dates together: -.IP -.nf -\f[C] -\-p2009/1/1to2009/4/1 -\-p"2009/1/1\ 2009/4/1" -\f[] -.fi +\f[C]\-p\ "from\ 2009/1/1\ to\ 2009/4/1"\f[] +.PP +Keywords like "from" and "to" are optional, and so are the spaces, as +long as you don\[aq]t run two dates together. +"to" can also be written as "\-". +These are equivalent to the above: +.PP +.TS +tab(@); +l. +T{ +\f[C]\-p\ "2009/1/1\ 2009/4/1"\f[] +T} +T{ +\f[C]\-p2009/1/1to2009/4/1\f[] +T} +T{ +\f[C]\-p2009/1/1\-2009/4/1\f[] +T} +.TE .PP Dates are smart dates, so if the current year is 2009, the above can also be written as: -.IP -.nf -\f[C] -\-p\ "1/1\ to\ 4/1" -\-p\ "january\ to\ apr" -\-p\ "this\ year\ to\ 4/1" -\f[] -.fi +.PP +.TS +tab(@); +l. +T{ +\f[C]\-p\ "1/1\ 4/1"\f[] +T} +T{ +\f[C]\-p\ "january\-apr"\f[] +T} +T{ +\f[C]\-p\ "this\ year\ to\ 4/1"\f[] +T} +.TE .PP If you specify only one date, the missing start or end date will be the earliest or latest transaction in your journal: -.IP -.nf -\f[C] -\-p\ "from\ 2009/1/1"\ \ (everything\ after\ january\ 1,\ 2009) -\-p\ "from\ 2009/1"\ \ \ \ (the\ same) -\-p\ "from\ 2009"\ \ \ \ \ \ (the\ same) -\-p\ "to\ 2009"\ \ \ \ \ \ \ \ (everything\ before\ january\ 1,\ 2009) -\f[] -.fi +.PP +.TS +tab(@); +l l. +T{ +\f[C]\-p\ "from\ 2009/1/1"\f[] +T}@T{ +everything after january 1, 2009 +T} +T{ +\f[C]\-p\ "from\ 2009/1"\f[] +T}@T{ +the same +T} +T{ +\f[C]\-p\ "from\ 2009"\f[] +T}@T{ +the same +T} +T{ +\f[C]\-p\ "to\ 2009"\f[] +T}@T{ +everything before january 1, 2009 +T} +.TE .PP A single date with no "from" or "to" defines both the start and end date like so: -.IP -.nf -\f[C] -\-p\ "2009"\ \ \ \ \ \ \ \ \ \ \ (the\ year\ 2009;\ \ \ \ equivalent\ to\ "2009/1/1\ to\ 2010/1/1") -\-p\ "2009/1"\ \ \ \ \ \ \ \ \ (the\ month\ of\ jan;\ equivalent\ to\ "2009/1/1\ to\ 2009/2/1") -\-p\ "2009/1/1"\ \ \ \ \ \ \ (just\ that\ day;\ \ \ \ equivalent\ to\ "2009/1/1\ to\ 2009/1/2") -\f[] -.fi +.PP +.TS +tab(@); +l l. +T{ +\f[C]\-p\ "2009"\f[] +T}@T{ +the year 2009; equivalent to "2009/1/1 to 2010/1/1" +T} +T{ +\f[C]\-p\ "2009/1"\f[] +T}@T{ +the month of jan; equivalent to "2009/1/1 to 2009/2/1" +T} +T{ +\f[C]\-p\ "2009/1/1"\f[] +T}@T{ +just that day; equivalent to "2009/1/1 to 2009/1/2" +T} +.TE .PP Period expressions can also start with (or be) a reporting interval: \f[C]daily\f[], \f[C]weekly\f[], \f[C]monthly\f[], \f[C]quarterly\f[], @@ -453,19 +494,35 @@ Period expressions can also start with (or be) a reporting interval: Optionally the word \f[C]in\f[] may appear between the reporting interval and the start/end dates. Examples: -.IP -.nf -\f[C] -\-p\ "weekly\ from\ 2009/1/1\ to\ 2009/4/1" -\-p\ "monthly\ in\ 2008" -\-p\ "bimonthly\ from\ 2008" -\-p\ "quarterly" -\-p\ "every\ 2\ weeks" -\-p\ "every\ 5\ days\ from\ 1/3" -\-p\ "every\ 15th\ day\ of\ month" -\-p\ "every\ 4th\ day\ of\ week" -\f[] -.fi +.PP +.TS +tab(@); +l. +T{ +\f[C]\-p\ "weekly\ from\ 2009/1/1\ to\ 2009/4/1"\f[] +T} +T{ +\f[C]\-p\ "monthly\ in\ 2008"\f[] +T} +T{ +\f[C]\-p\ "bimonthly\ from\ 2008"\f[] +T} +T{ +\f[C]\-p\ "quarterly"\f[] +T} +T{ +\f[C]\-p\ "every\ 2\ weeks"\f[] +T} +T{ +\f[C]\-p\ "every\ 5\ days\ from\ 1/3"\f[] +T} +T{ +\f[C]\-p\ "every\ 15th\ day\ of\ month"\f[] +T} +T{ +\f[C]\-p\ "every\ 4th\ day\ of\ week"\f[] +T} +.TE .SS Regular Expressions .PP hledger uses regular expressions in a number of places: @@ -937,6 +994,9 @@ balances of any subaccounts. Accounts which have zero balance (and no non\-zero subaccounts) are omitted. Use \f[C]\-E/\-\-empty\f[] to show them. +.PP +A final total is displayed by default; use \f[C]\-N/\-\-no\-total\f[] to +suppress it: .IP .nf \f[C] @@ -946,10 +1006,14 @@ $\ hledger\ balance\ \-p\ 2008/6\ expenses\ \-\-no\-total \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ supplies \f[] .fi -.PP -A final total is displayed by default; use \f[C]\-N/\-\-no\-total\f[] to -suppress it. .SS Flat mode +.PP +To see a flat list of full account names instead of the default +hierarchical display, use \f[C]\-\-flat\f[]. +In this mode, accounts (unless depth\-clipped) show their "exclusive" +balance, excluding any subaccount balances. +In this mode, you can also use \f[C]\-\-drop\ N\f[] to omit the first +few account name components. .IP .nf \f[C] @@ -958,14 +1022,13 @@ $\ hledger\ balance\ \-p\ 2008/6\ expenses\ \-N\ \-\-flat\ \-\-drop\ 1 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ supplies \f[] .fi -.PP -To see a flat list of full account names instead of the default -hierarchical display, use \f[C]\-\-flat\f[]. -In this mode, accounts (unless depth\-clipped) show their "exclusive" -balance, excluding any subaccount balances. -In this mode, you can also use \f[C]\-\-drop\ N\f[] to omit the first -few account name components. .SS Depth limiting +.PP +With \f[C]\-\-depth\ N\f[], balance shows accounts only to the specified +depth. +This is very useful to show a complex charts of accounts in less detail. +In flat mode, balances from accounts below the depth limit will be shown +as part of a parent account at the depth limit. .IP .nf \f[C] @@ -976,18 +1039,17 @@ $\ hledger\ balance\ \-N\ \-\-depth\ 1 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities \f[] .fi -.PP -With \f[C]\-\-depth\ N\f[], balance shows accounts only to the specified -depth. -This is very useful to show a complex charts of accounts in less detail. -In flat mode, balances from accounts below the depth limit will be shown -as part of a parent account at the depth limit. .SS Multicolumn balance reports .PP With a reporting interval, multiple balance columns will be shown, one for each report period. There are three types of multi\-column balance report, showing different information: +.IP "1." 3 +By default: each column shows the sum of postings in that period, ie the +account\[aq]s change of balance in that period. +This is useful eg for a monthly income statement: +.RS 4 .IP .nf \f[C] @@ -1004,10 +1066,12 @@ Balance\ changes\ in\ 2008: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \f[] .fi -.IP "1." 3 -By default: each column shows the sum of postings in that period, ie the -account\[aq]s change of balance in that period. -This is useful eg for a monthly income statement. +.RE +.IP "2." 3 +With \f[C]\-\-cumulative\f[]: each column shows the ending balance for +that period, accumulating the changes across periods, starting from 0 at +the report start date: +.RS 4 .IP .nf \f[C] @@ -1024,26 +1088,18 @@ Ending\ balances\ (cumulative)\ in\ 2008: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \f[] .fi -.IP "2." 3 -With \f[C]\-\-cumulative\f[]: each column shows the ending balance for -that period, accumulating the changes across periods, starting from 0 at -the report start date. -This mode is not often used. +.RE +.IP "3." 3 +With \f[C]\-\-historical/\-H\f[]: each column shows the actual +historical ending balance for that period, accumulating the changes +across periods, 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 only the data after a certain start date: +.RS 4 .IP .nf \f[C] -$\ hledger\ balance\ ^assets\ ^liabilities\ \-Q\ -Balance\ changes\ in\ 2008: - -\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008q1\ \ 2008q2\ \ 2008q3\ \ 2008q4\ -======================++================================= -\ assets:bank:checking\ ||\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ $\-1\ -\ assets:bank:saving\ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\ assets:cash\ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ $\-2\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\ liabilities:debts\ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- -\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ $1\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ - $\ hledger\ balance\ ^assets\ ^liabilities\ \-\-quarterly\ \-\-historical\ \-\-begin\ 2008/4/1 Ending\ balances\ (historical)\ in\ 2008/04/01\-2008/12/31: @@ -1057,17 +1113,37 @@ Ending\ balances\ (historical)\ in\ 2008/04/01\-2008/12/31: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \f[] .fi -.IP "3." 3 -With \f[C]\-\-historical/\-H\f[]: each column shows the actual -historical ending balance for that period, accumulating the changes -across periods, 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 only the data after a certain start date. +.RE +.PP +Multi\-column balance reports display accounts in flat mode by default; +to see the hierarchy, use \f[C]\-\-tree\f[]. +.PP +With a reporting interval (like \f[C]\-\-quarterly\f[] above), the +report start/end dates will be adjusted if necessary so that they +encompass the displayed report periods. +This is so that the first and last periods will be "full" and comparable +to the others. +.PP +The \f[C]\-E/\-\-empty\f[] flag does two things in multicolumn balance +reports: first, the report will show all columns within the specified +report period (without \-E, leading and trailing columns with all zeroes +are not shown). +Second, all accounts which existed at the report start date will be +considered, not just the ones with activity during the report period +(use \-E to include low\-activity accounts which would otherwise would +be omitted). +.PP +The \f[C]\-T/\-\-row\-total\f[] flag adds an additional column showing +the total for each row. +.PP +The \f[C]\-A/\-\-average\f[] flag adds a column showing the average +value in each row. +.PP +Here\[aq]s an example of all three: .IP .nf \f[C] -$\ hledger\ balance\ \-Q\ income\ expenses\ \-\-tree\ \-E\ \-TA +$\ hledger\ balance\ \-Q\ income\ expenses\ \-\-tree\ \-ETA Balance\ changes\ in\ 2008: \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008q1\ \ 2008q2\ \ 2008q3\ \ 2008q4\ \ \ \ Total\ \ Average\ @@ -1084,30 +1160,6 @@ Balance\ changes\ in\ 2008: #\ Average\ is\ rounded\ to\ the\ dollar\ here\ since\ all\ journal\ amounts\ are \f[] .fi -.PP -Multi\-column balance reports display accounts in flat mode by default; -to see the hierarchy, use \f[C]\-\-tree\f[]. -.PP -Note that with a reporting interval, the report start/end dates will be -"enlarged" if necessary so that they encompass the displayed report -periods. -This is so that the first and last periods will be "full" and comparable -to the others. -.PP -The \f[C]\-E/\-\-empty\f[] flag does two things here: first, the report -will show all columns within the specified report period (without \-E, -leading and trailing columns with all zeroes are not shown). -Second, all accounts which existed at the report start date will be -considered, not just the ones with activity during the report period -(use \-E to include low\-activity accounts which would otherwise would -be omitted). -.PP -The \f[C]\-T/\-\-row\-total\f[] flag adds an additional column showing -the total for each row. -The \f[C]\-A/\-\-average\f[] flag adds a column showing the average -value in each row. -Note in \f[C]\-\-H/\-\-historical\f[] mode only the average is useful, -and in \f[C]\-\-cumulative\f[] mode neither is useful. .SS Market value .PP The \f[C]\-V/\-\-value\f[] flag converts all the reported amounts to @@ -1121,6 +1173,9 @@ with P directives, ignoring transaction prices recorded as part of posting amounts (which \-B/\-\-cost uses). Using \-B and \-V together is allowed. .SS Custom balance output +.PP +In simple (non\-multi\-column) balance reports, you can customise the +output with \f[C]\-\-format\ FMT\f[]: .IP .nf \f[C] @@ -1140,17 +1195,18 @@ $\ hledger\ balance\ \-\-format\ "%20(account)\ %12(total)" \f[] .fi .PP -In simple (non\-multi\-column) balance reports, you can customise the -output with \f[C]\-\-format\ FMT\f[]. -FMT (plus a newline) will be displayed for each account/balance pair. -It is a format string with data fields interpolated by +The FMT format string (plus a newline) specifies the formatting applied +to each account/balance pair. +It may contain any suitable text, with data fields interpolated like so: .PP \f[C]%[MIN][.MAX](FIELDNAME)\f[] -.PP -where MIN means pad with spaces to at least this width, and MAX means -truncate at this width. -The field name must be enclosed in parentheses. -Three fields are available: +.IP \[bu] 2 +MIN pads with spaces to at least this width (optional) +.IP \[bu] 2 +MAX truncates at this width (optional) +.IP \[bu] 2 +FIELDNAME must be enclosed in parentheses, and can be one of: +.RS 2 .IP \[bu] 2 \f[C]depth_spacer\f[] \- a number of spaces equal to the account\[aq]s depth, or if MIN is specified, MIN * depth spaces. @@ -1159,39 +1215,40 @@ depth, or if MIN is specified, MIN * depth spaces. .IP \[bu] 2 \f[C]total\f[] \- the account\[aq]s balance/posted total, right justified +.RE .PP -When the total has multiple commodities, by default each commodity is -displayed on a separate line, and the report item will be bottom -aligned. -You can change how such multi\-line values are rendered by beginning the -format with a special prefix: +Also, FMT can begin with an optional prefix to control how +multi\-commodity amounts are rendered: .IP \[bu] 2 \f[C]%_\f[] \- render on multiple lines, bottom\-aligned (the default) .IP \[bu] 2 \f[C]%^\f[] \- render on multiple lines, top\-aligned .IP \[bu] 2 -\f[C]%,\f[] \- render on one line, with multi\-line values -comma\-separated +\f[C]%,\f[] \- render on one line, comma\-separated .PP -There are some quirks, and experimentation may be needed to get pleasing -output. -In one\-line mode, \f[C]%(depth_spacer)\f[] has no effect, instead +There are some quirks. +Eg in one\-line mode, \f[C]%(depth_spacer)\f[] has no effect, instead \f[C]%(account)\f[] has indentation built in. + Experimentation may be needed to get pleasing results. .PP -Examples: +Some example formats: .IP \[bu] 2 \f[C]%(total)\f[] \- the account\[aq]s total .IP \[bu] 2 \f[C]%\-20.20(account)\f[] \- the account\[aq]s name, left justified, padded to 20 characters and clipped at 20 characters .IP \[bu] 2 -\f[C]%20(total)\ \ %2(depth_spacer)%\-(account)\f[] \- default format -for the single\-column balance report -.IP \[bu] 2 \f[C]%,%\-50(account)\ \ %25(total)\f[] \- account name padded to 50 characters, total padded to 20 characters, with multiple commodities rendered on one line +.IP \[bu] 2 +\f[C]%20(total)\ \ %2(depth_spacer)%\-(account)\f[] \- the default +format for the single\-column balance report .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] @@ -1199,18 +1256,7 @@ $\ hledger\ balance\ \-o\ \-\ \ \ \ \ #\ write\ to\ stdout\ (the\ default) $\ hledger\ balance\ \-o\ FILE\ \ #\ write\ to\ FILE \f[] .fi -.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. .SS CSV output -.IP -.nf -\f[C] -$\ hledger\ balance\ \-O\ csv\ \ \ \ \ \ \ #\ write\ CSV\ to\ stdout -$\ hledger\ balance\ \-o\ FILE.csv\ \ #\ write\ CSV\ to\ FILE.csv -\f[] -.fi .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 @@ -1218,6 +1264,13 @@ 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 .PP Show a balance sheet. @@ -1399,16 +1452,6 @@ select the output format. Supported formats: txt, csv. .RS .RE -.PP -The print command displays full transactions from the journal file, -tidily formatted and showing all amounts explicitly. -The output of print is always a valid hledger journal, but it does -always not preserve all original content exactly (eg directives). -.PP -hledger\[aq]s print command also shows all unit prices in effect, or -(with \-B/\-\-cost) shows cost amounts. -.PP -The print command also supports output destination and CSV output. .IP .nf \f[C] @@ -1435,6 +1478,16 @@ $\ hledger\ print \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1 \f[] .fi +.PP +The print command displays full transactions from the journal file, +tidily formatted and showing all amounts explicitly. +The output of print is always a valid hledger journal, but it does +always not preserve all original content exactly (eg directives). +.PP +hledger\[aq]s print command also shows all unit prices in effect, or +(with \-B/\-\-cost) shows cost amounts. +.PP +The print command also supports output destination and CSV output. .SS register .PP Show postings and their running total. @@ -1472,6 +1525,11 @@ select the output format. Supported formats: txt, csv. .RS .RE +.PP +The register command displays postings, one per line, and their running +total. +This is typically used with a query selecting a particular account, to +see that account\[aq]s activity: .IP .nf \f[C] @@ -1483,10 +1541,10 @@ $\ hledger\ register\ checking \f[] .fi .PP -The register command displays postings, one per line, and their running -total. -This is typically used with a query selecting a particular account, to -see that account\[aq]s activity. +The \f[C]\-\-historical\f[]/\f[C]\-H\f[] flag adds the balance from any +undisplayed prior postings to the running total. +This is useful when you want to see only recent activity, with a +historically accurate running balance: .IP .nf \f[C] @@ -1497,11 +1555,6 @@ $\ hledger\ register\ checking\ \-b\ 2008/6\ \-\-historical \f[] .fi .PP -The \f[C]\-\-historical\f[]/\f[C]\-H\f[] flag adds the balance from any -prior postings to the running total, to show the actual historical -running balance. -This is useful when you want to see just the recent activity. -.PP The \f[C]\-\-depth\f[] option limits the amount of sub\-account detail displayed. .PP @@ -1514,6 +1567,9 @@ It works best when showing just one account and one commodity. The \f[C]\-\-related\f[]/\f[C]\-r\f[] flag shows the \f[I]other\f[] postings in the transactions of the postings which would normally be shown. +.PP +With a reporting interval, register shows summary postings, one per +interval, aggregating the postings to each account: .IP .nf \f[C] @@ -1522,6 +1578,10 @@ $\ hledger\ register\ \-\-monthly\ income 2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ $\-2 \f[] .fi +.PP +Periods with no activity, and summary postings with a zero amount, are +not shown by default; use the \f[C]\-\-empty\f[]/\f[C]\-E\f[] flag to +see them: .IP .nf \f[C] @@ -1540,27 +1600,20 @@ $\ hledger\ register\ \-\-monthly\ income\ \-E 2008/12\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ $\-2 \f[] .fi +.PP +Often, you\[aq]ll want to see just one line per interval. +The \f[C]\-\-depth\f[] option helps with this, causing subaccounts to be +aggregated: .IP .nf \f[C] -$\ hledger\ register\ \-\-monthly\ assets\ \-\-depth\ 1\ \ #\ cashflow\ (changes\ to\ assets)\ by\ month +$\ hledger\ register\ \-\-monthly\ assets\ \-\-depth\ 1h 2008/01\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ \ $1 2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ \ \ 0 2008/12\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ $\-1 \f[] .fi .PP -With a reporting interval, register shows summary postings, one per -interval, aggregating the postings to each account. -.PP -Periods with no activity, and summary postings with a zero amount, are -not shown by default; use the \f[C]\-\-empty\f[]/\f[C]\-E\f[] flag to -see them. -.PP -Often, you\[aq]ll want to see just one line per interval. -The \f[C]\-\-depth\f[] option helps with this, causing subaccounts to be -aggregated. -.PP Note when using report intervals, if you specify start/end dates these will be adjusted outward if necessary to contain a whole number of intervals. @@ -1591,12 +1644,12 @@ and some examples: .IP .nf \f[C] -$\ hledger\ reg\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ terminal\ width\ (or\ 80\ on\ windows) -$\ hledger\ reg\ \-w\ 100\ \ \ \ \ \ \ \ \ \ #\ use\ width\ 100 -$\ COLUMNS=100\ hledger\ reg\ \ \ \ \ #\ set\ with\ one\-time\ environment\ variable -$\ 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\ $COLUMNS,40\ \ #\ use\ terminal\ width,\ and\ set\ description\ width +$\ hledger\ reg\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ terminal\ width\ (or\ 80\ on\ windows) +$\ hledger\ reg\ \-w\ 100\ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ width\ 100 +$\ COLUMNS=100\ hledger\ reg\ \ \ \ \ \ \ \ \ #\ set\ with\ one\-time\ environment\ variable +$\ 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\ $COLUMNS,40\ \ \ \ \ \ #\ use\ terminal\ width,\ and\ set\ description\ width \f[] .fi .PP diff --git a/hledger/doc/hledger.1.txt b/hledger/doc/hledger.1.txt index d97274dcf..f9b302933 100644 --- a/hledger/doc/hledger.1.txt +++ b/hledger/doc/hledger.1.txt @@ -90,6 +90,8 @@ EEXXAAMMPPLLEESS 2015/09/30 gift received assets:cash $20 $20 2015/10/16 farmers market assets:cash $-10 $10 + More commands: + $ hledger # show available commands $ hledger add # add more transactions to the journal file $ hledger balance # all accounts with aggregated balances @@ -222,15 +224,15 @@ OOPPTTIIOONNSS Examples: - tab(@); lw(33.7n) lw(36.3n). T{ 2009/1/1, 2009/01/01, 2009-1-1, - 2009.1.1 T}@T{ simple dates, several separators allowed T} T{ 2009/1, - 2009 T}@T{ same as above - a missing day or month defaults to 1 T} T{ - 1/1, january, jan, this year T}@T{ relative dates, meaning january 1 of - the current year T} T{ next year T}@T{ january 1 of next year T} T{ - this month T}@T{ the 1st of the current month T} T{ this week T}@T{ the - most recent monday T} T{ last week T}@T{ the monday of the week before - this one T} T{ lastweek T}@T{ spaces are optional T} T{ today, yester- - day, tomorrow T}@T{ T} + tab(@); l l. T{ 2009/1/1, 2009/01/01, 2009-1-1, 2009.1.1 T}@T{ simple + dates, several separators allowed T} T{ 2009/1, 2009 T}@T{ same as + above - a missing day or month defaults to 1 T} T{ 1/1, january, jan, + this year T}@T{ relative dates, meaning january 1 of the current year + T} T{ next year T}@T{ january 1 of next year T} T{ this month T}@T{ the + 1st of the current month T} T{ this week T}@T{ the most recent monday + T} T{ last week T}@T{ the monday of the week before this one T} T{ + lastweek T}@T{ spaces are optional T} T{ today, yesterday, tomorrow + T}@T{ T} RReeppoorrttiinngg iinntteerrvvaall A reporting interval can be specified so that commands like register, @@ -247,106 +249,107 @@ OOPPTTIIOONNSS hledger's period expressions are similar to Ledger's, though not iden- tical. Here's a basic period expression specifying the first quarter - of 2009. Note hledger always treats start dates as inclusive and end + of 2009. Note, hledger always treats start dates as inclusive and end dates as exclusive: - -p "from 2009/1/1 to 2009/4/1" + -p "from 2009/1/1 to 2009/4/1" - Keywords like "from" and "to" are optional, and so are the spaces. - Just don't run two dates together: + Keywords like "from" and "to" are optional, and so are the spaces, as + long as you don't run two dates together. "to" can also be written as + "-". These are equivalent to the above: - -p2009/1/1to2009/4/1 - -p"2009/1/1 2009/4/1" + + tab(@); l. T{ -p "2009/1/1 2009/4/1" T} T{ -p2009/1/1to2009/4/1 T} T{ + -p2009/1/1-2009/4/1 T} Dates are smart dates, so if the current year is 2009, the above can also be written as: - -p "1/1 to 4/1" - -p "january to apr" - -p "this year to 4/1" + + tab(@); l. T{ -p "1/1 4/1" T} T{ -p "january-apr" T} T{ + -p "this year to 4/1" T} If you specify only one date, the missing start or end date will be the earliest or latest transaction in your journal: - -p "from 2009/1/1" (everything after january 1, 2009) - -p "from 2009/1" (the same) - -p "from 2009" (the same) - -p "to 2009" (everything before january 1, 2009) - A single date with no "from" or "to" defines both the start and end + tab(@); l l. T{ -p "from 2009/1/1" T}@T{ everything after january 1, + 2009 T} T{ -p "from 2009/1" T}@T{ the same T} T{ -p "from 2009" T}@T{ + the same T} T{ -p "to 2009" T}@T{ everything before january 1, 2009 T} + + A single date with no "from" or "to" defines both the start and end date like so: - -p "2009" (the year 2009; equivalent to "2009/1/1 to 2010/1/1") - -p "2009/1" (the month of jan; equivalent to "2009/1/1 to 2009/2/1") - -p "2009/1/1" (just that day; equivalent to "2009/1/1 to 2009/1/2") + + tab(@); l l. T{ -p "2009" T}@T{ the year 2009; equivalent to "2009/1/1 + to 2010/1/1" T} T{ -p "2009/1" T}@T{ the month of jan; equivalent to + "2009/1/1 to 2009/2/1" T} T{ -p "2009/1/1" T}@T{ just that day; equiva- + lent to "2009/1/1 to 2009/1/2" T} Period expressions can also start with (or be) a reporting interval: daily, weekly, monthly, quarterly, yearly, or one of the every ... expressions below. Optionally the word in may appear between the reporting interval and the start/end dates. Examples: - -p "weekly from 2009/1/1 to 2009/4/1" - -p "monthly in 2008" - -p "bimonthly from 2008" - -p "quarterly" - -p "every 2 weeks" - -p "every 5 days from 1/3" - -p "every 15th day of month" - -p "every 4th day of week" + + tab(@); l. T{ -p "weekly from 2009/1/1 to 2009/4/1" T} T{ + -p "monthly in 2008" T} T{ -p "bimonthly from 2008" T} T{ -p "quar- + terly" T} T{ -p "every 2 weeks" T} T{ -p "every 5 days from 1/3" T} T{ + -p "every 15th day of month" T} T{ -p "every 4th day of week" T} RReegguullaarr EExxpprreessssiioonnss 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 +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 - hledger's regular expressions come from the regex-tdfa library. In + hledger's regular expressions come from the regex-tdfa library. In general they: +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) +o are POSIX extended regular expressions +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 +o do not support mode modifiers like (?s) Some things to note: - +o In the alias directive and --alias option, regular expressions must - be enclosed in forward slashes (/REGEX/). Elsewhere in hledger, + +o In the alias directive and --alias option, regular expressions must + be enclosed in forward slashes (/REGEX/). Elsewhere in hledger, these are not required. +o To match a regular expression metacharacter like $ as a literal char- acter, prepend a backslash. Eg to search for amounts 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 a second time, with single or - double quotes or another backslash. Eg, to match amounts with the + double quotes or another backslash. Eg, to match amounts with the dollar sign from the command line, write cur:'\$' or cur:\\$. QQUUEERRIIEESS - One of hledger's strengths is being able to quickly report on precise - subsets of your data. Most commands accept an optional query expres- - 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 + One of hledger's strengths is being able to quickly report on precise + subsets of your data. Most commands accept an optional query expres- + 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 web search: one or more space-separated search terms, quotes to enclose - whitespace, optional prefixes to match specific fields. Multiple + whitespace, optional prefixes to match specific fields. Multiple search terms are combined as follows: - All commands except print: show transactions/postings/accounts which + All commands except print: show transactions/postings/accounts which match (or negatively match) +o any of the description terms AND @@ -373,22 +376,22 @@ QQUUEERRIIEESS same as above aammtt::NN,, aammtt::<