mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
dev: ui: lens: Add classy lens instances for UIOpts and UIState.
This commit is contained in:
parent
09a2449f4f
commit
f471258a48
@ -103,3 +103,21 @@ getHledgerUIOpts = do
|
||||
let args' = replaceNumericFlags args
|
||||
let cmdargopts = either usageError id $ process uimode args'
|
||||
rawOptsToUIOpts cmdargopts
|
||||
|
||||
instance HasCliOpts UIOpts where
|
||||
cliOpts f uiopts = (\x -> uiopts{cliopts_=x}) <$> f (cliopts_ uiopts)
|
||||
|
||||
instance HasInputOpts UIOpts where
|
||||
inputOpts = cliOpts.inputOpts
|
||||
|
||||
instance HasBalancingOpts UIOpts where
|
||||
balancingOpts = cliOpts.balancingOpts
|
||||
|
||||
instance HasReportSpec UIOpts where
|
||||
reportSpec = cliOpts.reportSpec
|
||||
|
||||
instance HasReportOptsNoUpdate UIOpts where
|
||||
reportOptsNoUpdate = cliOpts.reportOptsNoUpdate
|
||||
|
||||
instance HasReportOpts UIOpts where
|
||||
reportOpts = cliOpts.reportOpts
|
||||
|
@ -48,6 +48,7 @@ import Text.Show.Functions ()
|
||||
-- import the Show instance for functions. Warning, this also re-exports it
|
||||
|
||||
import Hledger
|
||||
import Hledger.Cli (HasCliOpts(..))
|
||||
import Hledger.UI.UIOptions
|
||||
|
||||
-- | hledger-ui's application state. This holds one or more stateful screens.
|
||||
@ -160,7 +161,24 @@ type NumberedTransaction = (Integer, Transaction)
|
||||
-- mempty = list "" V.empty 1 -- XXX problem in 0.7, every list requires a unique Name
|
||||
-- mappend l1 l2 = l1 & listElementsL .~ (l1^.listElementsL <> l2^.listElementsL)
|
||||
|
||||
concat <$> mapM makeLenses [
|
||||
''Screen
|
||||
]
|
||||
makeLenses ''Screen
|
||||
|
||||
uioptslens f ui = (\x -> ui{aopts=x}) <$> f (aopts ui)
|
||||
|
||||
instance HasCliOpts UIState where
|
||||
cliOpts = uioptslens.cliOpts
|
||||
|
||||
instance HasInputOpts UIState where
|
||||
inputOpts = uioptslens.inputOpts
|
||||
|
||||
instance HasBalancingOpts UIState where
|
||||
balancingOpts = uioptslens.balancingOpts
|
||||
|
||||
instance HasReportSpec UIState where
|
||||
reportSpec = uioptslens.reportSpec
|
||||
|
||||
instance HasReportOptsNoUpdate UIState where
|
||||
reportOptsNoUpdate = uioptslens.reportOptsNoUpdate
|
||||
|
||||
instance HasReportOpts UIState where
|
||||
reportOpts = uioptslens.reportOpts
|
||||
|
Loading…
Reference in New Issue
Block a user