mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
ref: ui: Refactor code to eliminate requirement for change_ in UIOpts.
--change is already stored in balanceaccum_ in ReportOpts, so it does not need to be stored in UIOpts too.
This commit is contained in:
parent
50f73b7434
commit
54c73ff759
@ -29,7 +29,6 @@ import Hledger
|
||||
import Hledger.Cli hiding (progname,prognameandversion)
|
||||
import Hledger.UI.UIOptions
|
||||
import Hledger.UI.UITypes
|
||||
import Hledger.UI.UIState (toggleHistorical)
|
||||
import Hledger.UI.Theme
|
||||
import Hledger.UI.AccountsScreen
|
||||
import Hledger.UI.RegisterScreen
|
||||
@ -110,8 +109,7 @@ runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{inputopts_=_iopts,reportspec_=rsp
|
||||
depth_ =queryDepth $ _rsQuery rspec, -- query's depth part
|
||||
period_=periodfromoptsandargs, -- query's date part
|
||||
no_elide_=True, -- avoid squashing boring account names, for a more regular tree (unlike hledger)
|
||||
empty_=not $ empty_ ropts, -- show zero items by default, hide them with -E (unlike hledger)
|
||||
balanceaccum_=Historical -- show historical balances by default (unlike hledger)
|
||||
empty_=not $ empty_ ropts -- show zero items by default, hide them with -E (unlike hledger)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -155,7 +153,6 @@ runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{inputopts_=_iopts,reportspec_=rsp
|
||||
|
||||
ui =
|
||||
(sInit scr) d True $
|
||||
(if change_ uopts' then toggleHistorical else id) -- XXX
|
||||
UIState{
|
||||
astartupopts=uopts'
|
||||
,aopts=uopts'
|
||||
|
@ -6,9 +6,11 @@
|
||||
module Hledger.UI.UIOptions
|
||||
where
|
||||
|
||||
import Data.Default
|
||||
import Data.Default (def)
|
||||
import Data.List (intercalate)
|
||||
import System.Environment
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Lens.Micro (set)
|
||||
import System.Environment (getArgs)
|
||||
|
||||
import Hledger.Cli hiding (packageversion, progname, prognameandversion)
|
||||
import Hledger.UI.Theme (themeNames)
|
||||
@ -64,13 +66,11 @@ uimode = (mode "hledger-ui" (setopt "command" "ui" def)
|
||||
-- hledger-ui options, used in hledger-ui and above
|
||||
data UIOpts = UIOpts {
|
||||
watch_ :: Bool
|
||||
,change_ :: Bool
|
||||
,cliopts_ :: CliOpts
|
||||
} deriving (Show)
|
||||
|
||||
defuiopts = UIOpts
|
||||
{ watch_ = False
|
||||
, change_ = False
|
||||
, cliopts_ = def
|
||||
}
|
||||
|
||||
@ -78,10 +78,11 @@ defuiopts = UIOpts
|
||||
|
||||
rawOptsToUIOpts :: RawOpts -> IO UIOpts
|
||||
rawOptsToUIOpts rawopts = checkUIOpts <$> do
|
||||
cliopts <- rawOptsToCliOpts rawopts
|
||||
-- show historical balance by default (unlike hledger)
|
||||
let accum = fromMaybe Historical $ balanceAccumulationOverride rawopts
|
||||
cliopts <- set balanceaccum accum <$> rawOptsToCliOpts rawopts
|
||||
return defuiopts {
|
||||
watch_ = boolopt "watch" rawopts
|
||||
,change_ = boolopt "change" rawopts
|
||||
,cliopts_ = cliopts
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user