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
|
closemode = hledgerCommandMode
|
||||||
$(embedFileRelative "Hledger/Cli/Commands/Close.txt")
|
$(embedFileRelative "Hledger/Cli/Commands/Close.txt")
|
||||||
[flagNone ["closing"] (setboolopt "closing") "show just closing transaction"
|
[flagNone ["close"] (setboolopt "close") "show just closing transaction"
|
||||||
,flagNone ["opening"] (setboolopt "opening") "show just opening 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 ["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 ["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 ["close-acct"] (\s opts -> Right $ setopt "close-acct" 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 ["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 ["explicit","x"] (setboolopt "explicit") "show all amounts explicitly"
|
||||||
,flagNone ["interleaved"] (setboolopt "interleaved") "keep equity and non-equity postings adjacent"
|
,flagNone ["interleaved"] (setboolopt "interleaved") "keep equity and non-equity postings adjacent"
|
||||||
,flagNone ["show-costs"] (setboolopt "show-costs") "keep balances with different costs separate"
|
,flagNone ["show-costs"] (setboolopt "show-costs") "keep balances with different costs separate"
|
||||||
]
|
]
|
||||||
[generalflagsgroup1]
|
[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]")
|
([], Just $ argsFlag "[QUERY]")
|
||||||
|
|
||||||
-- debugger, beware: close is incredibly devious. simple rules combine to make a horrid maze.
|
-- 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
|
let
|
||||||
-- show opening entry, closing entry, or (default) both ?
|
-- show opening entry, closing entry, or (default) both ?
|
||||||
(opening, closing) =
|
(opening, closing) =
|
||||||
case (boolopt "opening" rawopts, boolopt "closing" rawopts) of
|
case (boolopt "open" rawopts, boolopt "close" rawopts) of
|
||||||
(False, False) -> (True, True)
|
(False, False) -> (True, True)
|
||||||
(o, c) -> (o, c)
|
(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
|
-- if only one is specified, it is used for both
|
||||||
(closingacct, openingacct) =
|
(closingacct, openingacct) =
|
||||||
let (mc, mo) =
|
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
|
in case (mc, mo) of
|
||||||
(Just c, Just o) -> (c, o)
|
(Just c, Just o) -> (c, o)
|
||||||
(Just c, Nothing) -> (c, c)
|
(Just c, Nothing) -> (c, c)
|
||||||
|
|||||||
@ -7,14 +7,12 @@ close out revenues/expenses to retained earnings at the end of a period.
|
|||||||
|
|
||||||
_FLAGS
|
_FLAGS
|
||||||
|
|
||||||
You can print just one of these transactions by using the
|
You can print just one of these transactions by using the `--close` or `--open` flag.
|
||||||
`--closing` or `--opening` flag.
|
You can customise their descriptions with the `--close-desc` and `--open-desc` options.
|
||||||
You can customise their descriptions with the
|
|
||||||
`--close-desc` and `--open-desc` options.
|
|
||||||
|
|
||||||
One amountless posting to "equity:opening/closing balances" is added
|
One amountless posting to "equity:opening/closing balances" is added
|
||||||
to balance the transactions, by default.
|
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.
|
if you specify only one of these, it will be used for both.
|
||||||
|
|
||||||
With `--x/--explicit`, the equity posting's amount will be shown.
|
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!*
|
*Warning: we use `>>` here to append; be careful not to type a single `>` which would wipe your journal!*
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ hledger close -f 2018.journal -e 2019 assets liabilities --opening >>2019.journal
|
$ hledger close -f 2018.journal -e 2019 assets liabilities --open >>2019.journal
|
||||||
$ hledger close -f 2018.journal -e 2019 assets liabilities --closing >>2018.journal
|
$ hledger close -f 2018.journal -e 2019 assets liabilities --close >>2018.journal
|
||||||
```
|
```
|
||||||
|
|
||||||
Now:
|
Now:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user