hledger/hledger/Hledger/Cli/Commands
Michael Kainer 79ca4a767e cli: Add -% to compound balance commands
This commit introduces the commandline argument -%/--percent to show
percentages of the column's total instead of the absolute amounts for
each account in reports. The signs of the values are preserved.

This option is especially useful for the balance and incomestatement
commands.

If there are multiple commodities involved in a report hledger bails
with an error message. This can be avoided by using --cost. Also note
that if one uses -% with the balance command the chances are high that
all numbers are 0. This is due to the fact that by default balance sums
up to zero. If one wants to use -% in a meaningful way with balance one
has to add a query.

In order to keep the implementation as simple as possible --tree has no
influence over how the percentages are calculated, i.e., the percentages
always represent the fraction of the columns total. If one wants to know
the percentages relative to a parent account, one has to use a query to
narrow down the accounts.
2019-11-18 17:10:59 -08:00
..
Accounts.hs code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Accounts.md acc: integrate CLI help & manual 2019-01-26 17:01:55 -08:00
Accounts.txt cli: command help: reduce width, line wrapping 2019-01-30 17:58:13 -08:00
Activity.hs code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Activity.md act: integrate CLI help & manual 2019-01-26 17:07:30 -08:00
Activity.txt cli: command help: reduce width, line wrapping 2019-01-30 17:58:13 -08:00
Add.hs ;lib: store raw opts unquoted 2019-10-19 14:44:08 -07:00
Add.md add: doc: mention the windows trailing-dot file path issue 2019-06-26 18:47:11 +01:00
Add.txt ;doc: update command help txt files 2019-07-26 23:25:52 +01:00
Balance.hs cli: Add -% to compound balance commands 2019-11-18 17:10:59 -08:00
Balance.md cli: Add -% to compound balance commands 2019-11-18 17:10:59 -08:00
Balance.txt ;doc: update command help txt files 2019-07-26 23:25:52 +01:00
Balancesheet.hs refactor: cli: commands: hlint clean 2019-02-14 05:15:49 -08:00
Balancesheet.md cli: Add -% to compound balance commands 2019-11-18 17:10:59 -08:00
Balancesheet.txt ;doc: update command help txt files 2019-07-26 23:25:52 +01:00
Balancesheetequity.hs refactor: cli: commands: hlint clean 2019-02-14 05:15:49 -08:00
Balancesheetequity.md doc: integrate CLI help & manual for remaining commands 2019-01-28 05:43:49 -08:00
Balancesheetequity.txt cli: command help: reduce width, line wrapping 2019-01-30 17:58:13 -08:00
Cashflow.hs refactor: cli: commands: hlint clean 2019-02-14 05:15:49 -08:00
Cashflow.md cli: Add -% to compound balance commands 2019-11-18 17:10:59 -08:00
Cashflow.txt cli: command help: reduce width, line wrapping 2019-01-30 17:58:13 -08:00
Checkdates.hs cli: restore --aux-date and --effective as --date2 aliases (#1034) 2019-06-02 08:48:41 -07:00
Checkdates.md doc: integrate CLI help & manual for remaining commands 2019-01-28 05:43:49 -08:00
Checkdates.txt cli: fix command help, really render as plain text 2019-01-30 12:44:10 -08:00
Checkdupes.hs code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Checkdupes.md doc: integrate CLI help & manual for remaining commands 2019-01-28 05:43:49 -08:00
Checkdupes.txt cli: fix command help, really render as plain text 2019-01-30 12:44:10 -08:00
Close.hs code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Close.md close: preserve transaction prices (costs) accurately (#1035) 2019-07-09 11:21:22 +01:00
Close.txt ;doc: update command help txt files 2019-07-26 23:25:52 +01:00
Commodities.hs refactor: cli: commands: hlint clean 2019-02-14 05:15:49 -08:00
Commodities.md commodities: add commodities command 2019-02-14 05:15:48 -08:00
Commodities.txt commodities: add commodities command 2019-02-14 05:15:48 -08:00
Descriptions.hs ;descriptions/notes/payees: fix build warning 2019-08-31 18:36:03 -07:00
Descriptions.md payees: Split command into descriptions, payees, and notes 2019-07-15 08:22:16 +01:00
Descriptions.txt ;doc: update command help txt files 2019-07-26 23:25:52 +01:00
Diff.hs diff: help tweaks (cf #981) 2019-03-09 09:45:30 -08:00
Diff.md diff: help tweaks (cf #981) 2019-03-09 09:45:30 -08:00
Diff.txt diff: help tweaks (cf #981) 2019-03-09 09:45:30 -08:00
Files.hs code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Files.md doc: integrate CLI help & manual for remaining commands 2019-01-28 05:43:49 -08:00
Files.txt cli: fix command help, really render as plain text 2019-01-30 12:44:10 -08:00
Help.hs code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Help.md ;api: another round of hledger-api purging; fix the build 2019-09-11 14:49:22 -07:00
Help.txt ;doc: regen manuals 2019-09-13 11:00:03 -07:00
Import.hs ;lib: store raw opts unquoted 2019-10-19 14:44:08 -07:00
Import.md import: --catchup marks all transactions imported, without importing 2019-09-13 08:43:33 -07:00
Import.txt ;doc: regen manuals 2019-09-13 11:00:03 -07:00
Incomestatement.hs refactor: cli: commands: hlint clean 2019-02-14 05:15:49 -08:00
Incomestatement.md cli: Add -% to compound balance commands 2019-11-18 17:10:59 -08:00
Incomestatement.txt cli: command help: reduce width, line wrapping 2019-01-30 17:58:13 -08:00
Notes.hs ;descriptions/notes/payees: fix build warning 2019-08-31 18:36:03 -07:00
Notes.md payees: Split command into descriptions, payees, and notes 2019-07-15 08:22:16 +01:00
Notes.txt ;doc: update command help txt files 2019-07-26 23:25:52 +01:00
Payees.hs ;descriptions/notes/payees: fix build warning 2019-08-31 18:36:03 -07:00
Payees.md payees: Split command into descriptions, payees, and notes 2019-07-15 08:22:16 +01:00
Payees.txt ;doc: update command help txt files 2019-07-26 23:25:52 +01:00
Prices.hs prices: style price amounts; always show full precision 2019-10-20 07:09:34 -07:00
Prices.md prices: style price amounts; always show full precision 2019-10-20 07:09:34 -07:00
Prices.txt ;doc: regen manuals 2019-10-23 12:30:27 -07:00
Print.hs code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Print.md ;doc: fix output destination/format links in command docs 2019-10-23 12:29:17 -07:00
Print.txt doc: don't use sed; fix accidental dedenting of some lists (#961) 2019-01-31 08:34:49 -08:00
Printunique.hs code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Printunique.md doc: integrate CLI help & manual for remaining commands 2019-01-28 05:43:49 -08:00
Printunique.txt cli: command help: reduce width, line wrapping 2019-01-30 17:58:13 -08:00
README.md doc: command docs readme -> .md 2019-01-30 17:59:42 -08:00
Register.hs reg: show negative amounts in red, like balance and Ledger 2019-08-21 07:11:55 +01:00
Register.md ;doc: fix output destination/format links in command docs 2019-10-23 12:29:17 -07:00
Register.txt regen cli help, manuals 2019-02-14 05:15:49 -08:00
Registermatch.hs code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Registermatch.md doc: integrate CLI help & manual for remaining commands 2019-01-28 05:43:49 -08:00
Registermatch.txt cli: fix command help, really render as plain text 2019-01-30 12:44:10 -08:00
Rewrite.hs ;lib: store raw opts unquoted 2019-10-19 14:44:08 -07:00
Rewrite.md ;doc: rewrite: consistent literal block styling 2019-05-07 16:11:35 -07:00
Rewrite.txt ;doc: update command help txt files 2019-07-26 23:25:52 +01:00
Roi.hs lib: roi does not fail on empty input data (+test) 2019-11-18 16:13:04 -08:00
Roi.md doc: integrate CLI help & manual for remaining commands 2019-01-28 05:43:49 -08:00
Roi.txt cli: fix command help, really render as plain text 2019-01-30 12:44:10 -08:00
Stats.hs ;lib: let commodityStylesFromAmounts & co. return an error (#793, #1091) 2019-09-27 15:09:39 -10:00
Stats.md ;doc: fix output destination/format links in command docs 2019-10-23 12:29:17 -07:00
Stats.txt ;doc: regen man pages 2019-09-01 08:53:06 -07:00
Tags.hs ;lib: store raw opts unquoted 2019-10-19 14:44:08 -07:00
Tags.md tags: add --values flag 2019-07-26 23:18:21 +01:00
Tags.txt ;doc: update command help txt files 2019-07-26 23:25:52 +01:00
Test.md doc: integrate CLI help & manual for remaining commands 2019-01-28 05:43:49 -08:00
Test.txt cli: fix command help, really render as plain text 2019-01-30 12:44:10 -08:00

hledgers built-in commands.

Each command has a similarly-named code module, Somecommand.hs, and documentation file, Somecommand.md.

The command doc is converted to plain text in Somecommand.txt, and which is included by Somecommand.hs to form command line help (the output of hledger COMMAND --help).

After changing md files, regenerating and committing the txt files is optional. If you dont do it, it will get done later (before release). It can be done by:

./Shake commandhelp

Or, by you can regenerate them while also building packages:

./Shake hledger   # or, all packages: ./Shake build

Builds made with stack, cabal, etc. wont notice changes in these md files, so use the above method if you need that.

The md files are also included by hledger/hledger_commands.m4.md to form the hledger manual, which can be regenerated with:

./Shake manuals [website]

Here are more special features/conventions of command doc files (see *.md for examples):

  • The content is pandoc markdown. m4 macros are not supported.

  • In manuals, they are rendered with formatting and hyperlinks when supported by the various output formats.

  • In command line help, they are rendered as plain text, with verbatim blocks unindented, and with lines longer than 78 characters wrapped (unless they contain no spaces).

  • To avoid unsightly line wrapping in command line help, try to keep verbatim examples to at most 78 characters wide. When necessary, we may be forced to cheat and alter command output slightly, eg reducing the width of registers typically 79-wide reports by one.

  • The first line should specify the command name and any aliases, as words separated by spaces and/or commas. It should end with a backslash (to force a line break in the output).

  • Short help, about one paragraph in length, should begin on the second line.

  • If the short help is more than one line, its first line should end with a single newline, not two (otherwise it will be displayed with two newlines after each line in command line help).

  • In command line help, the short help is displayed with blank lines removed (paragraphs run together). Blank lines can still be used for markdown formatting though, eg to define a list.

  • After the short help, there should be a paragraph containing just FLAGS. This marks the end of the short help, and it will be replaced in command line help by the flags list. (Without it, the flags list appears at the end of command line help.) The flags list will not appear in the hledger manual.

  • Long help (as many paragraphs as needed) follows the FLAGS marker. This often ends with one or more examples.

XXX Command docs with examples wider than 78: close rewrite