From 148ac4236f487b17e15797e17948dcb80a5a1a16 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 24 Nov 2016 11:32:13 -0800 Subject: [PATCH] ui: --change shows period balances (changes) at startup --- hledger-ui/Hledger/UI/Main.hs | 20 +++++++++++--------- hledger-ui/Hledger/UI/UIOptions.hs | 13 +++++++++++-- hledger-ui/doc/hledger-ui.1 | 5 +++++ hledger-ui/doc/hledger-ui.1.info | 27 +++++++++++++++------------ hledger-ui/doc/hledger-ui.1.m4.md | 3 +++ hledger-ui/doc/hledger-ui.1.txt | 3 +++ 6 files changed, 48 insertions(+), 23 deletions(-) diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index 4eb43847b..b48b98f36 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -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 { diff --git a/hledger-ui/Hledger/UI/UIOptions.hs b/hledger-ui/Hledger/UI/UIOptions.hs index 62f20fb44..e504540d2 100644 --- a/hledger-ui/Hledger/UI/UIOptions.hs +++ b/hledger-ui/Hledger/UI/UIOptions.hs @@ -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 } diff --git a/hledger-ui/doc/hledger-ui.1 b/hledger-ui/doc/hledger-ui.1 index b1cfef13c..ca5fa5fa6 100644 --- a/hledger-ui/doc/hledger-ui.1 +++ b/hledger-ui/doc/hledger-ui.1 @@ -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 diff --git a/hledger-ui/doc/hledger-ui.1.info b/hledger-ui/doc/hledger-ui.1.info index d84b9a227..d1a57659a 100644 --- a/hledger-ui/doc/hledger-ui.1.info +++ b/hledger-ui/doc/hledger-ui.1.info @@ -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 diff --git a/hledger-ui/doc/hledger-ui.1.m4.md b/hledger-ui/doc/hledger-ui.1.m4.md index 8f9e7da8a..9be1b75d0 100644 --- a/hledger-ui/doc/hledger-ui.1.m4.md +++ b/hledger-ui/doc/hledger-ui.1.m4.md @@ -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 diff --git a/hledger-ui/doc/hledger-ui.1.txt b/hledger-ui/doc/hledger-ui.1.txt index 8c6c2e951..456a13fca 100644 --- a/hledger-ui/doc/hledger-ui.1.txt +++ b/hledger-ui/doc/hledger-ui.1.txt @@ -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