mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-28 04:46:31 +03:00
close: regularise the --open*/--close* flags for memorability (#1165)
--closing -> --close --opening -> --open --close-to -> --close-acct --open-from -> --open-acct The old flags are still accepted for backward compatibility, but are not shown in --help or docs, to conserve screen and brain space.
This commit is contained in:
parent
cda8909aae
commit
5ba3cc6f42
@ -25,18 +25,24 @@ defopeningacct = defclosingacct
|
||||
|
||||
closemode = hledgerCommandMode
|
||||
$(embedFileRelative "Hledger/Cli/Commands/Close.txt")
|
||||
[flagNone ["closing"] (setboolopt "closing") "show just closing transaction"
|
||||
,flagNone ["opening"] (setboolopt "opening") "show just opening transaction"
|
||||
[flagNone ["close"] (setboolopt "close") "show just closing transaction"
|
||||
,flagNone ["open"] (setboolopt "open") "show just opening transaction"
|
||||
,flagReq ["close-desc"] (\s opts -> Right $ setopt "close-desc" s opts) "DESC" ("description for closing transaction (default: "++defclosingdesc++")")
|
||||
,flagReq ["open-desc"] (\s opts -> Right $ setopt "open-desc" s opts) "DESC" ("description for opening transaction (default: "++defopeningdesc++")")
|
||||
,flagReq ["close-to"] (\s opts -> Right $ setopt "close-to" s opts) "ACCT" ("account to transfer closing balances to (default: "++defclosingacct++")")
|
||||
,flagReq ["open-from"] (\s opts -> Right $ setopt "open-from" s opts) "ACCT" ("account to transfer opening balances from (default: "++defopeningacct++")")
|
||||
,flagReq ["close-acct"] (\s opts -> Right $ setopt "close-acct" s opts) "ACCT" ("account to transfer closing balances to (default: "++defclosingacct++")")
|
||||
,flagReq ["open-acct"] (\s opts -> Right $ setopt "open-acct" s opts) "ACCT" ("account to transfer opening balances from (default: "++defopeningacct++")")
|
||||
,flagNone ["explicit","x"] (setboolopt "explicit") "show all amounts explicitly"
|
||||
,flagNone ["interleaved"] (setboolopt "interleaved") "keep equity and non-equity postings adjacent"
|
||||
,flagNone ["show-costs"] (setboolopt "show-costs") "keep balances with different costs separate"
|
||||
]
|
||||
[generalflagsgroup1]
|
||||
hiddenflags
|
||||
(hiddenflags ++
|
||||
-- old close flags for compatibility, hidden
|
||||
[flagNone ["closing"] (setboolopt "close") "old spelling of --close"
|
||||
,flagNone ["opening"] (setboolopt "open") "old spelling of --open"
|
||||
,flagReq ["close-to"] (\s opts -> Right $ setopt "close-acct" s opts) "ACCT" ("old spelling of --close-acct")
|
||||
,flagReq ["open-from"] (\s opts -> Right $ setopt "open-acct" s opts) "ACCT" ("old spelling of --open-acct")
|
||||
])
|
||||
([], Just $ argsFlag "[QUERY]")
|
||||
|
||||
-- debugger, beware: close is incredibly devious. simple rules combine to make a horrid maze.
|
||||
@ -46,7 +52,7 @@ close CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do
|
||||
let
|
||||
-- show opening entry, closing entry, or (default) both ?
|
||||
(opening, closing) =
|
||||
case (boolopt "opening" rawopts, boolopt "closing" rawopts) of
|
||||
case (boolopt "open" rawopts, boolopt "close" rawopts) of
|
||||
(False, False) -> (True, True)
|
||||
(o, c) -> (o, c)
|
||||
|
||||
@ -58,7 +64,7 @@ close CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do
|
||||
-- if only one is specified, it is used for both
|
||||
(closingacct, openingacct) =
|
||||
let (mc, mo) =
|
||||
(T.pack <$> maybestringopt "close-to" rawopts, T.pack <$> maybestringopt "open-from" rawopts)
|
||||
(T.pack <$> maybestringopt "close-acct" rawopts, T.pack <$> maybestringopt "open-acct" rawopts)
|
||||
in case (mc, mo) of
|
||||
(Just c, Just o) -> (c, o)
|
||||
(Just c, Nothing) -> (c, c)
|
||||
|
@ -7,14 +7,12 @@ close out revenues/expenses to retained earnings at the end of a period.
|
||||
|
||||
_FLAGS
|
||||
|
||||
You can print just one of these transactions by using the
|
||||
`--closing` or `--opening` flag.
|
||||
You can customise their descriptions with the
|
||||
`--close-desc` and `--open-desc` options.
|
||||
You can print just one of these transactions by using the `--close` or `--open` flag.
|
||||
You can customise their descriptions with the `--close-desc` and `--open-desc` options.
|
||||
|
||||
One amountless posting to "equity:opening/closing balances" is added
|
||||
to balance the transactions, by default.
|
||||
You can customise this account name with `--close-to` and `--open-from`;
|
||||
You can customise this account name with `--close-acct` and `--open-acct`;
|
||||
if you specify only one of these, it will be used for both.
|
||||
|
||||
With `--x/--explicit`, the equity posting's amount will be shown.
|
||||
@ -71,8 +69,8 @@ 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!*
|
||||
|
||||
```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
|
||||
$ hledger close -f 2018.journal -e 2019 assets liabilities --open >>2019.journal
|
||||
$ hledger close -f 2018.journal -e 2019 assets liabilities --close >>2018.journal
|
||||
```
|
||||
|
||||
Now:
|
||||
|
Loading…
Reference in New Issue
Block a user