dev: lens: Introduce lenses for CliOpts.
This commit is contained in:
		
							parent
							
								
									f3eacebc1d
								
							
						
					
					
						commit
						bd113b223f
					
				| @ -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 ( | module Hledger.Cli.CliOptions ( | ||||||
| 
 | 
 | ||||||
| @ -35,6 +41,7 @@ module Hledger.Cli.CliOptions ( | |||||||
| 
 | 
 | ||||||
|   -- * CLI options |   -- * CLI options | ||||||
|   CliOpts(..), |   CliOpts(..), | ||||||
|  |   HasCliOpts(..), | ||||||
|   defcliopts, |   defcliopts, | ||||||
|   getHledgerCliOpts, |   getHledgerCliOpts, | ||||||
|   getHledgerCliOpts', |   getHledgerCliOpts', | ||||||
| @ -747,3 +754,22 @@ getDirectoryContentsSafe d = | |||||||
| --     putStrLn $ "processed opts:\n" ++ show opts | --     putStrLn $ "processed opts:\n" ++ show opts | ||||||
| --     d <- getCurrentDay | --     d <- getCurrentDay | ||||||
| --     putStrLn $ "search query: " ++ (show $ queryFromOpts d $ reportopts_ opts) | --     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 | ||||||
|  | |||||||
| @ -158,6 +158,7 @@ library | |||||||
|     , lucid |     , lucid | ||||||
|     , math-functions >=0.3.3.0 |     , math-functions >=0.3.3.0 | ||||||
|     , megaparsec >=7.0.0 && <9.2 |     , megaparsec >=7.0.0 && <9.2 | ||||||
|  |     , microlens >=0.4 | ||||||
|     , mtl >=2.2.1 |     , mtl >=2.2.1 | ||||||
|     , process |     , process | ||||||
|     , regex-tdfa |     , regex-tdfa | ||||||
| @ -207,6 +208,7 @@ executable hledger | |||||||
|     , hledger-lib >=1.22.99 && <1.23 |     , hledger-lib >=1.22.99 && <1.23 | ||||||
|     , math-functions >=0.3.3.0 |     , math-functions >=0.3.3.0 | ||||||
|     , megaparsec >=7.0.0 && <9.2 |     , megaparsec >=7.0.0 && <9.2 | ||||||
|  |     , microlens >=0.4 | ||||||
|     , mtl >=2.2.1 |     , mtl >=2.2.1 | ||||||
|     , process |     , process | ||||||
|     , regex-tdfa |     , regex-tdfa | ||||||
| @ -257,6 +259,7 @@ test-suite unittest | |||||||
|     , hledger-lib >=1.22.99 && <1.23 |     , hledger-lib >=1.22.99 && <1.23 | ||||||
|     , math-functions >=0.3.3.0 |     , math-functions >=0.3.3.0 | ||||||
|     , megaparsec >=7.0.0 && <9.2 |     , megaparsec >=7.0.0 && <9.2 | ||||||
|  |     , microlens >=0.4 | ||||||
|     , mtl >=2.2.1 |     , mtl >=2.2.1 | ||||||
|     , process |     , process | ||||||
|     , regex-tdfa |     , regex-tdfa | ||||||
| @ -306,6 +309,7 @@ benchmark bench | |||||||
|     , html |     , html | ||||||
|     , math-functions >=0.3.3.0 |     , math-functions >=0.3.3.0 | ||||||
|     , megaparsec >=7.0.0 && <9.2 |     , megaparsec >=7.0.0 && <9.2 | ||||||
|  |     , microlens >=0.4 | ||||||
|     , mtl >=2.2.1 |     , mtl >=2.2.1 | ||||||
|     , process |     , process | ||||||
|     , regex-tdfa |     , regex-tdfa | ||||||
|  | |||||||
| @ -112,6 +112,7 @@ dependencies: | |||||||
| - githash >=0.1.4 | - githash >=0.1.4 | ||||||
| - haskeline >=0.6 | - haskeline >=0.6 | ||||||
| - megaparsec >=7.0.0 && <9.2 | - megaparsec >=7.0.0 && <9.2 | ||||||
|  | - microlens >=0.4 | ||||||
| - mtl >=2.2.1 | - mtl >=2.2.1 | ||||||
| - process | - process | ||||||
| - regex-tdfa | - regex-tdfa | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user