ui: --change shows period balances (changes) at startup

This commit is contained in:
Simon Michael 2016-11-24 11:32:13 -08:00
parent b09b3a7be6
commit 148ac4236f
6 changed files with 48 additions and 23 deletions

View File

@ -33,7 +33,7 @@ import Hledger
import Hledger.Cli hiding (progname,prognameandversion,green) import Hledger.Cli hiding (progname,prognameandversion,green)
import Hledger.UI.UIOptions import Hledger.UI.UIOptions
import Hledger.UI.UITypes import Hledger.UI.UITypes
-- import Hledger.UI.UIUtils import Hledger.UI.UIState (toggleHistorical)
import Hledger.UI.Theme import Hledger.UI.Theme
import Hledger.UI.AccountsScreen import Hledger.UI.AccountsScreen
import Hledger.UI.RegisterScreen import Hledger.UI.RegisterScreen
@ -129,7 +129,9 @@ runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} j = do
,aMode=Normal ,aMode=Normal
} }
ui = (sInit scr) d True ui =
(sInit scr) d True $
(if change_ uopts' then toggleHistorical else id) $ -- XXX
UIState{ UIState{
aopts=uopts' aopts=uopts'
,ajournal=j ,ajournal=j

View File

@ -29,6 +29,12 @@ uiflags = [
flagNone ["watch"] (\opts -> setboolopt "watch" opts) "watch for data changes and reload automatically" flagNone ["watch"] (\opts -> setboolopt "watch" opts) "watch for data changes and reload automatically"
,flagReq ["theme"] (\s opts -> Right $ setopt "theme" s opts) "THEME" ("use this custom display theme ("++intercalate ", " themeNames++")") ,flagReq ["theme"] (\s opts -> Right $ setopt "theme" s opts) "THEME" ("use this custom display theme ("++intercalate ", " themeNames++")")
,flagReq ["register"] (\s opts -> Right $ setopt "register" s opts) "ACCTREGEX" "start in the (first) matched account's register" ,flagReq ["register"] (\s opts -> Right $ setopt "register" s opts) "ACCTREGEX" "start in the (first) matched account's register"
,flagNone ["change"] (\opts -> setboolopt "change" opts)
"show period balances (changes) at startup"
-- ,flagNone ["cumulative"] (\opts -> setboolopt "cumulative" opts)
-- "show balance change accumulated across periods (in multicolumn reports)"
-- ,flagNone ["historical","H"] (\opts -> setboolopt "historical" opts)
-- "show historical ending balance in each period (includes postings before report start date)\n "
,flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show full account names, unindented" ,flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show full account names, unindented"
-- ,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "with --flat, omit this many leading account name components" -- ,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "with --flat, omit this many leading account name components"
-- ,flagReq ["format"] (\s opts -> Right $ setopt "format" s opts) "FORMATSTR" "use this custom line format" -- ,flagReq ["format"] (\s opts -> Right $ setopt "format" s opts) "FORMATSTR" "use this custom line format"
@ -53,12 +59,14 @@ uimode = (mode "hledger-ui" [("command","ui")]
-- hledger-ui options, used in hledger-ui and above -- hledger-ui options, used in hledger-ui and above
data UIOpts = UIOpts { data UIOpts = UIOpts {
watch_ :: Bool watch_ :: Bool
,change_ :: Bool
,cliopts_ :: CliOpts ,cliopts_ :: CliOpts
} deriving (Show) } deriving (Show)
defuiopts = UIOpts defuiopts = UIOpts
def def
def def
def
-- instance Default CliOpts where def = defcliopts -- instance Default CliOpts where def = defcliopts
@ -67,6 +75,7 @@ rawOptsToUIOpts rawopts = checkUIOpts <$> do
cliopts <- rawOptsToCliOpts rawopts cliopts <- rawOptsToCliOpts rawopts
return defuiopts { return defuiopts {
watch_ = boolopt "watch" rawopts watch_ = boolopt "watch" rawopts
,change_ = boolopt "change" rawopts
,cliopts_ = cliopts ,cliopts_ = cliopts
} }

View File

@ -54,6 +54,11 @@ start in the (first) matched account\[aq]s register screen
.RS .RS
.RE .RE
.TP .TP
.B \f[C]\-\-change\f[]
show period balances (changes) at startup
.RS
.RE
.TP
.B \f[C]\-\-flat\f[] .B \f[C]\-\-flat\f[]
show full account names, unindented show full account names, unindented
.RS .RS

View File

@ -46,6 +46,9 @@ the data.
`--register=ACCTREGEX' `--register=ACCTREGEX'
start in the (first) matched account's register screen start in the (first) matched account's register screen
`--change'
show period balances (changes) at startup
`--flat' `--flat'
show full account names, unindented show full account names, unindented
@ -354,17 +357,17 @@ Tag Table:
Node: Top88 Node: Top88
Node: OPTIONS823 Node: OPTIONS823
Ref: #options922 Ref: #options922
Node: KEYS3850 Node: KEYS3909
Ref: #keys3947 Ref: #keys4006
Node: SCREENS6348 Node: SCREENS6407
Ref: #screens6435 Ref: #screens6494
Node: Accounts screen6525 Node: Accounts screen6584
Ref: #accounts-screen6655 Ref: #accounts-screen6714
Node: Register screen8693 Node: Register screen8752
Ref: #register-screen8850 Ref: #register-screen8909
Node: Transaction screen10738 Node: Transaction screen10797
Ref: #transaction-screen10898 Ref: #transaction-screen10957
Node: Error screen11765 Node: Error screen11824
Ref: #error-screen11889 Ref: #error-screen11948
 
End Tag Table End Tag Table

View File

@ -58,6 +58,9 @@ Any QUERYARGS are interpreted as a hledger search query which filters the data.
`--register=ACCTREGEX` `--register=ACCTREGEX`
: start in the (first) matched account's register screen : start in the (first) matched account's register screen
`--change`
: show period balances (changes) at startup
`--flat` `--flat`
: show full account names, unindented : show full account names, unindented

View File

@ -44,6 +44,9 @@ OPTIONS
--register=ACCTREGEX --register=ACCTREGEX
start in the (first) matched account's register screen start in the (first) matched account's register screen
--change
show period balances (changes) at startup
--flat show full account names, unindented --flat show full account names, unindented
-V --value -V --value