diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 7a9f88695..340d6444b 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -5,7 +5,13 @@ related utilities used by hledger commands. -} -{-# LANGUAGE CPP, ScopedTypeVariables, FlexibleContexts, TypeFamilies, OverloadedStrings, PackageImports #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE PackageImports #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeFamilies #-} module Hledger.Cli.CliOptions ( @@ -35,6 +41,7 @@ module Hledger.Cli.CliOptions ( -- * CLI options CliOpts(..), + HasCliOpts(..), defcliopts, getHledgerCliOpts, getHledgerCliOpts', @@ -747,3 +754,22 @@ getDirectoryContentsSafe d = -- putStrLn $ "processed opts:\n" ++ show opts -- d <- getCurrentDay -- putStrLn $ "search query: " ++ (show $ queryFromOpts d $ reportopts_ opts) + +-- ** Lenses + +makeHledgerClassyLenses ''CliOpts + +instance HasInputOpts CliOpts where + inputOpts = inputopts + +instance HasBalancingOpts CliOpts where + balancingOpts = inputOpts.balancingOpts + +instance HasReportSpec CliOpts where + reportSpec = reportspec + +instance HasReportOptsNoUpdate CliOpts where + reportOptsNoUpdate = reportSpec.reportOptsNoUpdate + +instance HasReportOpts CliOpts where + reportOpts = reportSpec.reportOpts diff --git a/hledger/hledger.cabal b/hledger/hledger.cabal index 242297f8f..544ed856c 100644 --- a/hledger/hledger.cabal +++ b/hledger/hledger.cabal @@ -158,6 +158,7 @@ library , lucid , math-functions >=0.3.3.0 , megaparsec >=7.0.0 && <9.2 + , microlens >=0.4 , mtl >=2.2.1 , process , regex-tdfa @@ -207,6 +208,7 @@ executable hledger , hledger-lib >=1.22.99 && <1.23 , math-functions >=0.3.3.0 , megaparsec >=7.0.0 && <9.2 + , microlens >=0.4 , mtl >=2.2.1 , process , regex-tdfa @@ -257,6 +259,7 @@ test-suite unittest , hledger-lib >=1.22.99 && <1.23 , math-functions >=0.3.3.0 , megaparsec >=7.0.0 && <9.2 + , microlens >=0.4 , mtl >=2.2.1 , process , regex-tdfa @@ -306,6 +309,7 @@ benchmark bench , html , math-functions >=0.3.3.0 , megaparsec >=7.0.0 && <9.2 + , microlens >=0.4 , mtl >=2.2.1 , process , regex-tdfa diff --git a/hledger/package.yaml b/hledger/package.yaml index 83905ce25..6d7f98739 100644 --- a/hledger/package.yaml +++ b/hledger/package.yaml @@ -112,6 +112,7 @@ dependencies: - githash >=0.1.4 - haskeline >=0.6 - megaparsec >=7.0.0 && <9.2 +- microlens >=0.4 - mtl >=2.2.1 - process - regex-tdfa