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.UI.UIOptions
import Hledger.UI.UITypes
-- import Hledger.UI.UIUtils
import Hledger.UI.UIState (toggleHistorical)
import Hledger.UI.Theme
import Hledger.UI.AccountsScreen
import Hledger.UI.RegisterScreen
@ -129,14 +129,16 @@ runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} j = do
,aMode=Normal
}
ui = (sInit scr) d True
UIState{
aopts=uopts'
,ajournal=j
,aScreen=scr
,aPrevScreens=prevscrs
,aMode=Normal
}
ui =
(sInit scr) d True $
(if change_ uopts' then toggleHistorical else id) $ -- XXX
UIState{
aopts=uopts'
,ajournal=j
,aScreen=scr
,aPrevScreens=prevscrs
,aMode=Normal
}
brickapp :: App (UIState) AppEvent Name
brickapp = App {

View File

@ -29,6 +29,12 @@ uiflags = [
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 ["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"
-- ,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"
@ -52,13 +58,15 @@ uimode = (mode "hledger-ui" [("command","ui")]
-- hledger-ui options, used in hledger-ui and above
data UIOpts = UIOpts {
watch_ :: Bool
,cliopts_ :: CliOpts
watch_ :: Bool
,change_ :: Bool
,cliopts_ :: CliOpts
} deriving (Show)
defuiopts = UIOpts
def
def
def
-- instance Default CliOpts where def = defcliopts
@ -67,6 +75,7 @@ rawOptsToUIOpts rawopts = checkUIOpts <$> do
cliopts <- rawOptsToCliOpts rawopts
return defuiopts {
watch_ = boolopt "watch" rawopts
,change_ = boolopt "change" rawopts
,cliopts_ = cliopts
}

View File

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

View File

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

End Tag Table

View File

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

View File

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