acc: integrate CLI help & manual

This commit is contained in:
Simon Michael 2019-01-26 17:00:46 -08:00
parent d1411fbd8d
commit f68309b106
7 changed files with 414 additions and 598 deletions

View File

@ -13,6 +13,7 @@ The @accounts@ command lists account names:
{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
module Hledger.Cli.Commands.Accounts ( module Hledger.Cli.Commands.Accounts (
@ -33,31 +34,17 @@ import Hledger.Cli.CliOptions
-- | Command line options for this command. -- | Command line options for this command.
accountsmode = (defCommandMode $ ["accounts"] ++ aliases) { accountsmode = hledgerCommandMode
modeHelp = "show account names" `withAliases` aliases $(hereFileRelative "Hledger/Cli/Commands/Accounts.md")
,modeHelpSuffix = [ [flagNone ["declared"] (\opts -> setboolopt "declared" opts) "show account names declared with account directives"
"This command lists account names, either declared with account directives" ,flagNone ["used"] (\opts -> setboolopt "used" opts) "show account names referenced by transactions"
,"(--declared), posted to (--used), or both (default)." ,flagNone ["tree"] (\opts -> setboolopt "tree" opts) "show short account names, as a tree"
,"With query arguments, only matched account names and account names" ,flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show full account names, as a list (default)"
,"referenced by matched postings are shown." ,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"
,"It shows a flat list by default. With `--tree`, it uses indentation to" ]
,"show the account hierarchy." [generalflagsgroup1]
,"In flat mode you can add `--drop N` to omit the first few account name components." []
,"Account names can be depth-clipped with `--depth N` or depth:N." ([], Just $ argsFlag "[QUERY]")
]
,modeGroupFlags = C.Group {
groupUnnamed = [
flagNone ["declared"] (\opts -> setboolopt "declared" opts) "show account names declared with account directives"
,flagNone ["used"] (\opts -> setboolopt "used" opts) "show account names referenced by transactions"
,flagNone ["tree"] (\opts -> setboolopt "tree" opts) "show short account names, as a tree"
,flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show full account names, as a list (default)"
,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"
]
,groupHidden = []
,groupNamed = [generalflagsgroup1]
}
}
where aliases = ["a"]
-- | The accounts command. -- | The accounts command.
accounts :: CliOpts -> Journal -> IO () accounts :: CliOpts -> Journal -> IO ()

View File

@ -0,0 +1,27 @@
accounts, a\
Show account names.
_FLAGS_
This command lists account names, either declared with account directives
(--declared), posted to (--used), or both (the default).
With query arguments, only matched account names and account names
referenced by matched postings are shown.
It shows a flat list by default. With `--tree`, it uses indentation to
show the account hierarchy.
In flat mode you can add `--drop N` to omit the first few account name components.
Account names can be depth-clipped with `depth:N` or `--depth N` or `-N`.
Examples:
```shell
$ hledger accounts
assets:bank:checking
assets:bank:saving
assets:cash
expenses:food
expenses:supplies
income:gifts
income:salary
liabilities:debts
```

View File

@ -23,6 +23,7 @@ It has some special features:
- Markdown can be used to influence the appearance of the manuals, - Markdown can be used to influence the appearance of the manuals,
especially the html version. But the markup will also appear especially the html version. But the markup will also appear
uninterpreted in the --help output, so use sparingly. uninterpreted in the --help output, so use sparingly.
m4 macros can not be used.
- Use only one newline on the first line (or cmdargs will display the - Use only one newline on the first line (or cmdargs will display the
short help with two newlines after each line). This also means short help with two newlines after each line). This also means

View File

@ -1350,36 +1350,14 @@ See also \f[C]hledger\f[] for a more organised command list, and
\f[C]hledger\ CMD\ \-h\f[] for detailed command help. \f[C]hledger\ CMD\ \-h\f[] for detailed command help.
.SS accounts .SS accounts
.PP .PP
accounts, a
.PD 0
.P
.PD
Show account names. Show account names.
Alias: a.
.TP
.B \f[C]\-\-declared\f[]
show account names declared with account directives
.RS
.RE
.TP
.B \f[C]\-\-used\f[]
show account names posted to by transactions
.RS
.RE
.TP
.B \f[C]\-\-tree\f[]
show short account names and their parents, as a tree
.RS
.RE
.TP
.B \f[C]\-\-flat\f[]
show full account names, as a list (default)
.RS
.RE
.TP
.B \f[C]\-\-drop=N\f[]
in flat mode: omit N leading account name parts
.RS
.RE
.PP .PP
This command lists account names, either declared with account This command lists account names, either declared with account
directives (\-\-declared), posted to (\-\-used), or both (default). directives (\-\-declared), posted to (\-\-used), or both (the default).
With query arguments, only matched account names and account names With query arguments, only matched account names and account names
referenced by matched postings are shown. referenced by matched postings are shown.
It shows a flat list by default. It shows a flat list by default.
@ -1387,46 +1365,13 @@ With \f[C]\-\-tree\f[], it uses indentation to show the account
hierarchy. hierarchy.
In flat mode you can add \f[C]\-\-drop\ N\f[] to omit the first few In flat mode you can add \f[C]\-\-drop\ N\f[] to omit the first few
account name components. account name components.
Account names can be depth\-clipped with \f[C]\-\-depth\ N\f[] or Account names can be depth\-clipped with \f[C]depth:N\f[] or
depth:N. \f[C]\-\-depth\ N\f[] or \f[C]\-N\f[].
.PP .PP
Examples: Examples:
.IP .IP
.nf .nf
\f[C] \f[C]
$\ hledger\ accounts\ \-\-tree
assets
\ \ bank
\ \ \ \ checking
\ \ \ \ saving
\ \ cash
expenses
\ \ food
\ \ supplies
income
\ \ gifts
\ \ salary
liabilities
\ \ debts
\f[]
.fi
.IP
.nf
\f[C]
$\ hledger\ accounts\ \-\-drop\ 1
bank:checking
bank:saving
cash
food
supplies
gifts
salary
debts
\f[]
.fi
.IP
.nf
\f[C]
$\ hledger\ accounts $\ hledger\ accounts
assets:bank:checking assets:bank:checking
assets:bank:saving assets:bank:saving

View File

@ -1020,60 +1020,20 @@ File: hledger.info, Node: accounts, Next: activity, Up: COMMANDS
4.1 accounts 4.1 accounts
============ ============
Show account names. Alias: a. accounts, a
Show account names.
'--declared'
show account names declared with account directives
'--used'
show account names posted to by transactions
'--tree'
show short account names and their parents, as a tree
'--flat'
show full account names, as a list (default)
'--drop=N'
in flat mode: omit N leading account name parts
This command lists account names, either declared with account This command lists account names, either declared with account
directives (-declared), posted to (-used), or both (default). With directives (-declared), posted to (-used), or both (the default). With
query arguments, only matched account names and account names referenced query arguments, only matched account names and account names referenced
by matched postings are shown. It shows a flat list by default. With by matched postings are shown. It shows a flat list by default. With
'--tree', it uses indentation to show the account hierarchy. In flat '--tree', it uses indentation to show the account hierarchy. In flat
mode you can add '--drop N' to omit the first few account name mode you can add '--drop N' to omit the first few account name
components. Account names can be depth-clipped with '--depth N' or components. Account names can be depth-clipped with 'depth:N' or
depth:N. '--depth N' or '-N'.
Examples: Examples:
$ hledger accounts --tree
assets
bank
checking
saving
cash
expenses
food
supplies
income
gifts
salary
liabilities
debts
$ hledger accounts --drop 1
bank:checking
bank:saving
cash
food
supplies
gifts
salary
debts
$ hledger accounts $ hledger accounts
assets:bank:checking assets:bank:checking
assets:bank:saving assets:bank:saving
@ -1970,8 +1930,7 @@ File: hledger.info, Node: close, Next: files, Prev: check-dupes, Up: COMMAND
========== ==========
close, equity close, equity
Prints a "closing balances" transaction and an "opening balances"
Prints a "closing balances" transaction and an "opening balances"
transaction that bring account balances to and from zero, respectively. transaction that bring account balances to and from zero, respectively.
Useful for bringing asset/liability balances forward into a new journal Useful for bringing asset/liability balances forward into a new journal
file, or for closing out revenues/expenses to retained earnings at the file, or for closing out revenues/expenses to retained earnings at the
@ -2802,98 +2761,98 @@ Node: COMMANDS32539
Ref: #commands32651 Ref: #commands32651
Node: accounts33651 Node: accounts33651
Ref: #accounts33749 Ref: #accounts33749
Node: activity34995 Node: activity34448
Ref: #activity35105 Ref: #activity34558
Node: add35465 Node: add34918
Ref: #add35564 Ref: #add35017
Node: balance38225 Node: balance37678
Ref: #balance38336 Ref: #balance37789
Node: Classic balance report41456 Node: Classic balance report40909
Ref: #classic-balance-report41629 Ref: #classic-balance-report41082
Node: Customising the classic balance report42998 Node: Customising the classic balance report42451
Ref: #customising-the-classic-balance-report43226 Ref: #customising-the-classic-balance-report42679
Node: Colour support45300 Node: Colour support44753
Ref: #colour-support45467 Ref: #colour-support44920
Node: Flat mode45640 Node: Flat mode45093
Ref: #flat-mode45788 Ref: #flat-mode45241
Node: Depth limited balance reports46201 Node: Depth limited balance reports45654
Ref: #depth-limited-balance-reports46401 Ref: #depth-limited-balance-reports45854
Node: Multicolumn balance report46857 Node: Multicolumn balance report46310
Ref: #multicolumn-balance-report47055 Ref: #multicolumn-balance-report46508
Node: Budget report52295 Node: Budget report51748
Ref: #budget-report52438 Ref: #budget-report51891
Node: Nested budgets57122 Node: Nested budgets56575
Ref: #nested-budgets57234 Ref: #nested-budgets56687
Ref: #output-format-160714 Ref: #output-format-160167
Node: balancesheet60792 Node: balancesheet60245
Ref: #balancesheet60928 Ref: #balancesheet60381
Node: balancesheetequity63239 Node: balancesheetequity62692
Ref: #balancesheetequity63388 Ref: #balancesheetequity62841
Node: cashflow63925 Node: cashflow63378
Ref: #cashflow64053 Ref: #cashflow63506
Node: check-dates66176 Node: check-dates65629
Ref: #check-dates66303 Ref: #check-dates65756
Node: check-dupes66420 Node: check-dupes65873
Ref: #check-dupes66544 Ref: #check-dupes65997
Node: close66681 Node: close66134
Ref: #close66789 Ref: #close66242
Node: files70206 Node: files69655
Ref: #files70307 Ref: #files69756
Node: help70448 Node: help69897
Ref: #help70548 Ref: #help69997
Node: import71622 Node: import71071
Ref: #import71736 Ref: #import71185
Node: incomestatement72466 Node: incomestatement71915
Ref: #incomestatement72600 Ref: #incomestatement72049
Node: prices75004 Node: prices74453
Ref: #prices75119 Ref: #prices74568
Node: print75391 Node: print74840
Ref: #print75501 Ref: #print74950
Node: print-unique80395 Node: print-unique79844
Ref: #print-unique80521 Ref: #print-unique79970
Node: register80589 Node: register80038
Ref: #register80716 Ref: #register80165
Node: Custom register output85217 Node: Custom register output84666
Ref: #custom-register-output85346 Ref: #custom-register-output84795
Node: register-match86576 Node: register-match86025
Ref: #register-match86710 Ref: #register-match86159
Node: rewrite86893 Node: rewrite86342
Ref: #rewrite87008 Ref: #rewrite86457
Node: roi87077 Node: roi86526
Ref: #roi87175 Ref: #roi86624
Node: stats87291 Node: stats86740
Ref: #stats87390 Ref: #stats86839
Node: tags88260 Node: tags87709
Ref: #tags88358 Ref: #tags87807
Node: test88594 Node: test88043
Ref: #test88678 Ref: #test88127
Node: ADD-ON COMMANDS89386 Node: ADD-ON COMMANDS88835
Ref: #add-on-commands89496 Ref: #add-on-commands88945
Node: Official add-ons90783 Node: Official add-ons90232
Ref: #official-add-ons90923 Ref: #official-add-ons90372
Node: api91010 Node: api90459
Ref: #api91099 Ref: #api90548
Node: ui91151 Node: ui90600
Ref: #ui91250 Ref: #ui90699
Node: web91308 Node: web90757
Ref: #web91397 Ref: #web90846
Node: Third party add-ons91443 Node: Third party add-ons90892
Ref: #third-party-add-ons91618 Ref: #third-party-add-ons91067
Node: diff91753 Node: diff91202
Ref: #diff91850 Ref: #diff91299
Node: iadd91949 Node: iadd91398
Ref: #iadd92063 Ref: #iadd91512
Node: interest92146 Node: interest91595
Ref: #interest92267 Ref: #interest91716
Node: irr92362 Node: irr91811
Ref: #irr92460 Ref: #irr91909
Node: Experimental add-ons92591 Node: Experimental add-ons92040
Ref: #experimental-add-ons92743 Ref: #experimental-add-ons92192
Node: autosync93023 Node: autosync92472
Ref: #autosync93134 Ref: #autosync92583
Node: chart93373 Node: chart92822
Ref: #chart93492 Ref: #chart92941
Node: check93563 Node: check93012
Ref: #check93665 Ref: #check93114
 
End Tag Table End Tag Table

File diff suppressed because it is too large Load Diff

View File

@ -24,76 +24,8 @@ for each command: name, synopsis, description, examples.
--> -->
## accounts ## accounts
Show account names. Alias: a.
`--declared` _include_(Hledger/Cli/Commands/Accounts.md)
: show account names declared with account directives
`--used`
: show account names posted to by transactions
`--tree`
: show short account names and their parents, as a tree
`--flat`
: show full account names, as a list (default)
`--drop=N`
: in flat mode: omit N leading account name parts
This command lists account names, either declared with account directives
(--declared), posted to (--used), or both (default).
With query arguments, only matched account names and account names
referenced by matched postings are shown.
It shows a flat list by default. With `--tree`, it uses indentation to
show the account hierarchy.
In flat mode you can add `--drop N` to omit the first few account name components.
Account names can be depth-clipped with `--depth N` or depth:N.
Examples:
_col3_({{
_shell_({{
$ hledger accounts --tree
assets
bank
checking
saving
cash
expenses
food
supplies
income
gifts
salary
liabilities
debts
}})
}},{{
_shell_({{
$ hledger accounts --drop 1
bank:checking
bank:saving
cash
food
supplies
gifts
salary
debts
}})
}},{{
_shell_({{
$ hledger accounts
assets:bank:checking
assets:bank:saving
assets:cash
expenses:food
expenses:supplies
income:gifts
income:salary
liabilities:debts
}})
}})
## activity ## activity
Show an ascii barchart of posting counts per interval. Show an ascii barchart of posting counts per interval.