From 040f2ba1bf0377f9ceae371804e58ba047b923b9 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 3 May 2019 11:21:16 -0700 Subject: [PATCH] doc: cli: consistent examples styling [ci skip] --- hledger/Hledger/Cli/Commands/Close.md | 41 ++++++++++++++---------- hledger/Hledger/Cli/Commands/Import.md | 4 ++- hledger/Hledger/Cli/Commands/Print.md | 2 +- hledger/Hledger/Cli/Commands/Register.md | 2 +- hledger/Hledger/Cli/Commands/Rewrite.md | 10 +++--- hledger/hledger_options.m4.md | 16 ++++----- 6 files changed, 42 insertions(+), 33 deletions(-) diff --git a/hledger/Hledger/Cli/Commands/Close.md b/hledger/Hledger/Cli/Commands/Close.md index 33b223363..ee710d8a8 100644 --- a/hledger/Hledger/Cli/Commands/Close.md +++ b/hledger/Hledger/Cli/Commands/Close.md @@ -48,30 +48,37 @@ Carrying asset/liability balances into a new file for 2019, all from command lin *Warning: we use `>>` here to append; be careful not to type a single `>` which would wipe your journal!* - $ hledger close -f 2018.journal -e 2019 assets liabilities --opening >>2019.journal - $ hledger close -f 2018.journal -e 2019 assets liabilities --closing >>2018.journal +```shell +$ hledger close -f 2018.journal -e 2019 assets liabilities --opening >>2019.journal +$ hledger close -f 2018.journal -e 2019 assets liabilities --closing >>2018.journal +``` Now: - $ hledger bs -f 2019.journal # one file - balances are correct - $ hledger bs -f 2018.journal -f 2019.journal # two files - balances still correct - $ hledger bs -f 2018.journal not:desc:closing # to see year-end balances, must exclude closing txn +```shell +$ hledger bs -f 2019.journal # one file - balances are correct +$ hledger bs -f 2018.journal -f 2019.journal # two files - balances still correct +$ hledger bs -f 2018.journal not:desc:closing # to see year-end balances, must exclude closing txn +``` Transactions spanning the closing date can complicate matters, breaking balance assertions: - 2018/12/30 a purchase made in 2018, clearing the following year - expenses:food 5 - assets:bank:checking -5 ; [2019/1/2] +```journal +2018/12/30 a purchase made in 2018, clearing the following year + expenses:food 5 + assets:bank:checking -5 ; [2019/1/2] +``` Here's one way to resolve that: - ; in 2018.journal: - 2018/12/30 a purchase made in 2018, clearing the following year - expenses:food 5 - liabilities:pending - - ; in 2019.journal: - 2019/1/2 clearance of last year's pending transactions - liabilities:pending 5 = 0 - assets:checking +```journal +; in 2018.journal: +2018/12/30 a purchase made in 2018, clearing the following year + expenses:food 5 + liabilities:pending +; in 2019.journal: +2019/1/2 clearance of last year's pending transactions + liabilities:pending 5 = 0 + assets:checking +``` diff --git a/hledger/Hledger/Cli/Commands/Import.md b/hledger/Hledger/Cli/Commands/Import.md index 05b039764..90ec39004 100644 --- a/hledger/Hledger/Cli/Commands/Import.md +++ b/hledger/Hledger/Cli/Commands/Import.md @@ -30,7 +30,9 @@ As a result, importing entries with balance assignments will probably generate incorrect posting amounts. To avoid this problem, use print instead of import: - $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE +```shell +$ hledger print IMPORTFILE [--new] >> $LEDGER_FILE +``` (If you think import should leave amounts implicit like print does, please test it and send a pull request.) diff --git a/hledger/Hledger/Cli/Commands/Print.md b/hledger/Hledger/Cli/Commands/Print.md index dd9c679e9..9eaf6ea16 100644 --- a/hledger/Hledger/Cli/Commands/Print.md +++ b/hledger/Hledger/Cli/Commands/Print.md @@ -58,7 +58,7 @@ with newer dates (and new transactions on the latest date) are printed. This is useful for ignoring already-seen entries in import data, such as downloaded CSV files. Eg: -```console +```shell $ hledger -f bank1.csv print --new # shows transactions added since last print --new on this file ``` diff --git a/hledger/Hledger/Cli/Commands/Register.md b/hledger/Hledger/Cli/Commands/Register.md index c226c7276..fe8781a91 100644 --- a/hledger/Hledger/Cli/Commands/Register.md +++ b/hledger/Hledger/Cli/Commands/Register.md @@ -46,7 +46,7 @@ displayed as negative numbers. It's also useful to show postings on the checking account together with the related account: -``` +```shell $ hledger register --related --invert assets:checking ``` diff --git a/hledger/Hledger/Cli/Commands/Rewrite.md b/hledger/Hledger/Cli/Commands/Rewrite.md index 6c40cc75f..8474d741d 100644 --- a/hledger/Hledger/Cli/Commands/Rewrite.md +++ b/hledger/Hledger/Cli/Commands/Rewrite.md @@ -10,13 +10,13 @@ but adds one or more specified postings to any transactions matching QUERY. The posting amounts can be fixed, or a multiplier of the existing transaction's first posting amount. Examples: -``` -hledger-rewrite.hs ^income --add-posting '(liabilities:tax) *.33 ; income tax' --add-posting '(reserve:gifts) $100' -hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts) *-1"' -hledger-rewrite.hs -f rewrites.hledger +```shell +$ hledger-rewrite.hs ^income --add-posting '(liabilities:tax) *.33 ; income tax' --add-posting '(reserve:gifts) $100' +$ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts) *-1"' +$ hledger-rewrite.hs -f rewrites.hledger ``` rewrites.hledger may consist of entries like: -``` +```journal = ^income amt:<0 date:2017 (liabilities:tax) *0.33 ; tax on income (reserve:grocery) *0.25 ; reserve 25% for grocery diff --git a/hledger/hledger_options.m4.md b/hledger/hledger_options.m4.md index 805eccef2..374776681 100644 --- a/hledger/hledger_options.m4.md +++ b/hledger/hledger_options.m4.md @@ -149,17 +149,17 @@ hledger reads transactions from a data file (and the add command writes to it). By default this file is `$HOME/.hledger.journal` (or on Windows, something like `C:/Users/USER/.hledger.journal`). You can override this with the `$LEDGER_FILE` environment variable: -```bash +```shell $ setenv LEDGER_FILE ~/finance/2016.journal $ hledger stats ``` or with the `-f/--file` option: -```bash +```shell $ hledger -f /some/file stats ``` The file name `-` (hyphen) means standard input: -```bash +```shell $ cat some.journal | hledger -f- ``` @@ -178,7 +178,7 @@ or if that is not recognised, by trying each built-in "reader" in turn: If needed (eg to ensure correct error messages when a file has the "wrong" extension), you can force a specific reader/format by prepending it to the file path with a colon. Examples: -```bash +```shell $ hledger -f csv:/some/csv-file.dat stats $ echo 'i 2009/13/1 08:00:00' | hledger print -ftimeclock:- ``` @@ -436,7 +436,7 @@ $ hledger balance --pivot member tag:member=. -2 EUR ``` Another way (the acct: query matches against the pivoted "account name"): -``` +```shell $ hledger balance --pivot member acct:. -2 EUR John Doe -------------------- @@ -468,17 +468,17 @@ P 2016/11/01 € $1.10 P 2016/12/21 € $1.03 ``` How many euros do I have ? -``` +```shell $ hledger -f t.j bal -N euros €100 assets:euros ``` What are they worth at end of nov 3 ? -``` +```shell $ hledger -f t.j bal -N euros -V -e 2016/11/4 $110.00 assets:euros ``` What are they worth after 2016/12/21 ? (no report end date specified, defaults to today) -``` +```shell $ hledger -f t.j bal -N euros -V $103.00 assets:euros ```